Clear Filters
Clear Filters

How to store vector in column matrix?

5 views (last 30 days)
So here is my for loop:
for i=1:1000
x=randfixedsum(5,1,1,0,1);
ret= x(1)*Returns(:,1) +x(2)*Returns(:,2) +x(3)*Returns(:,3) +x(4)*Returns(:,4) +x(5)*Returns(:,5);
am=mean(ret)*251;
as=std(ret)*sqrt(251);
hold all
plot(as,am,'r.')
end
x is a 1x5 matrix that changes each loop, I am looking to store the values of each loop in a matrix so I know what values were used on each loop.
I tried adding in a
y=[x(i);x(i+1)];
But that just gave an error. Any help would be great thanks

Accepted Answer

Ameer Hamza
Ameer Hamza on 13 May 2018
Outside for loop define
y = zeros(1000, 5);
and then inside for loop use
x=randfixedsum(5,1,1,0,1);
y(i, :) = x;
all the values will be stored in y.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!