Hi I have a for loop. The result of every iteration is a rowvector. I want all rowvectors of the for loop stored as one matrix. Each row is the result of one iteration.
Simplified example:
if true
X= 1:0.1:2;
for i = 1:length(X)
A=4
B= 1:5
Y= A.*X(i)+B
end
end
The end result shoud be an 11 x 5 matrix. Indexing will give errors, so will starting with an empty array.
4 Comments
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/484378-how-to-store-vectors-from-each-for-loop-in-a-matrix#comment_754377
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/484378-how-to-store-vectors-from-each-for-loop-in-a-matrix#comment_754377
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/484378-how-to-store-vectors-from-each-for-loop-in-a-matrix#comment_754383
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/484378-how-to-store-vectors-from-each-for-loop-in-a-matrix#comment_754383
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/484378-how-to-store-vectors-from-each-for-loop-in-a-matrix#comment_754392
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/484378-how-to-store-vectors-from-each-for-loop-in-a-matrix#comment_754392
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/484378-how-to-store-vectors-from-each-for-loop-in-a-matrix#comment_754409
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/484378-how-to-store-vectors-from-each-for-loop-in-a-matrix#comment_754409
Sign in to comment.