i wanted to ask this:
If i have this matrix:
magnetT=NaN(Maxstep,2);
and want to prepend to it the "{0 1}"
how can i write it?
Also,if i have this in mathematica in a loop:
magnetT[[i]] = {T, Apply[Plus, Flatten[mlat]]/L2}
the equivalent in matlab isn't this???
magnetT(i,2)=[T ,sum(mlat(:))./L2];
because it gives me :Subscripted assignment dimension mismatch.
Error in ==> metropolis at 128 magnetT(i,2)=[T,sum(mlat(:))./L2];
Thanks
I'll attempt to answer
your first questionboth questions.You asked about prepending the NaN array to {0,1} which is a cell array. Any data objects can be readily bundled into a cell array:
If you are instead trying to concatenate the results into a numeric matrix, the following will help:
For your second question, MATLAB is complaining about trying to store a vector in one element of
magnetT
. When computing:the right-hand side will create a vector while the left-hand side is trying to store that vector where a scalar is expected. I don't know exactly what you're trying to achieve and I'm not very familiar with Mathematica syntax but perhaps you need to do this instead:
or, in other words: