Azzera filtri
Azzera filtri

How to store vector in column matrix?

5 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Ameer Hamza
Ameer Hamza il 13 Mag 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.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by