In: Electrical Engineering
I see theres solution posted but its done in Mathmatica format.
Can someone show me the solution using Matlab, please? Consider a particle in a room. How likely is the particle to hit the east wall of the room? Assume the western wall repels the particles and there is no vertical motion. The position at a subsequent time is related to the current position by x^n+1 = z^n + f(x^n) + Noise where f(x) = k/x^2 so that the force away from the western wall at x = 0 is proportional to the inverse of the distance squared. The noise is given by e times a random number between minus one and one. The eastern wall is taken to be at x = 5 and the constant of proportionality for the repulsive force is k = 0.5, with a noise amplitude of 1. Run at least 200 experiments and determine how many runs it took to reach the eastern wall. Plot the results.
ans:
This problem has to be done by programming in Mathematica since you need a random number generation and runs upto 200 times.I have written down the program for running the script 200 times with k=0.5 and western wall to be at origin x=0.
I take the initial position x0 to be 0.25,0.5,0.75... till 4.75.For each value of x0, I find the number of runs taken to reach x=5.
The program is as follows:(in Mathematica):
Array[x, 200];
k = 0.5;
\[Epsilon] = 1;
For[j = 0.25, j < 5, j = j + 0.25, x[1] = j; Print["=x0"
j];
For[i = 1, i <= 200, i++,
x[i + 1] = x[i] + (k/(x[i]^2)) + \[Epsilon]*RandomReal[{-1,
1}];
If[x[i] > 5, Print["=i" i]; i = 200]]]
-------------------------------------------------
Now, here the ouput comes as ,
The plot is also shown.The X Axis corresponds to x0=initial position. And the Y Axis corresponds to the number of runs needed to reach eastern wall.
pls rate thumsup