Filter löschen
Filter löschen

How to store vector in column matrix?

5 Ansichten (letzte 30 Tage)
Phil Whitfield
Phil Whitfield am 13 Mai 2018
Kommentiert: Phil Whitfield am 13 Mai 2018
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

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 13 Mai 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.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by