Borrar filtros
Borrar filtros

How to store vector in column matrix?

5 visualizaciones (últimos 30 días)
Phil Whitfield
Phil Whitfield el 13 de Mayo de 2018
Comentada: Phil Whitfield el 13 de Mayo de 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

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 13 de Mayo de 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.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by