Reputation: 1
I'm got a script that produce a column of 36 values. I would save these 36 values in rows in Excel.
At the moment, I have to run the script each time so I can change the xlrange value, eg: A1 to A1000.
I tried looping the script, and tried to write the values into a new column of a new variable, say mm
.
For i=1:1000
Scriptnamehere
mm(i,:)=m or mm(:,i)
Write in excel script here
End
It failed to recognize i for mm
.
Upvotes: 0
Views: 70
Reputation: 2541
Maybe use simple assignemt mm = m (I suppose m is the value You got from the script), in You case You tried to assign 36 values to for example mm(1), which would not work. On the other hand I would not recomend to use i
as variable for the looping, because it is already predefined by Matlab as imaginary number
For i=1:1000
Scriptnamehere
mm = m
Write in excel script here
End
Upvotes: 1
Reputation: 4648
You have to preallocate the Matrix mm
:
N = 1000; % number of iterations
num_rows = 36; % number of values in every iteration
mm = zeros(num_rows, N); % preallocation
for k = 1:N % don't use i as index variable
% call script with k, receive m
mm(:, k) = m;
end
Upvotes: 1