- #1
ggeo1
- 63
- 0
Hello ,i have the following problem in mathematica and want to do it in matlab.
mathematica :
And i did this :
I have two problems:
1) The result from r2D is always "1" but it must change values.
2) I can't handle the "data" with Map function in mathematica.I now i must do an arrayfun(f,x) and x=10:20:90 but i am confused how to type it.
mathematica :
Code:
...
Walk1D[n_] := FoldList[Plus, 0, steps[n]]
LastPoint1D[n_] := Fold[Plus, 0, steps[n]]
...
nsteps = 200; nsq = Floor[Sqrt[nsteps]];
MeanSquareDistance1D[n_Integer, m_Integer] :=
N[Sum[LastPoint1D[n]^2, {m}]/m]
r2D=MeanSquareDistance1D[100, 1000]
data = Map[({#, MeanSquareDistance1D[#,2000]})&,
Range[10, 90, 20]]
And i did this :
Code:
Walk1D =@ (n) cumsum(steps(n));
LastPoint1D_old=@ (n) cumsum(steps(n));
LastPoint1D=@ (n) LastPoint1D(end);
nsteps=200;
nsq=floor(sqrt(nsteps));
MeanSquareDistance1D= @ (n,m) m*sum(LastPoint1D(n).^2)/.m;
r2D=MeanSquareDistance1D(100,1000)
I have two problems:
1) The result from r2D is always "1" but it must change values.
2) I can't handle the "data" with Map function in mathematica.I now i must do an arrayfun(f,x) and x=10:20:90 but i am confused how to type it.