how to save output of for loop
95 views (last 30 days)
Hi, I have a matrix A=54×100. For some specific condition I perform an operation on each row of “A” with the help of for loop. now I need to save the output of this for loop. I tried like
but not succeed.
Alexandra Harkai on 28 Feb 2017
The size of output S in this case will be 54*20. To specify that you want to assign answer to the whole row of S, use the same (i,:) indexing you used for A:
More Answers (2)
Jan on 28 Feb 2017
This works without a loop also:
S = squeeze(mean(reshape(Ri, size(A, 1), 5, 20), 2));
MARCO FORTI on 25 Oct 2019
I am doing forecasting and the algorithm works fine, nevertheless I can not save the output as I would.
In particular, the final loop is:
In this I only get the general output as "ans", while I would get the two vector "ff" and "th" both in sequence (as "ans" reports) and separately.
Can anyone help me?