for loops iterations into array

1 visualización (últimos 30 días)
Christopher
Christopher el 7 de Mzo. de 2013
For every K value i want to put it in a vector with 12 columns (due to the 12 iterations of i) then end that and go to the next k which is 1 and go to the next i iteration which is from 1:12. Then i wanna do the same thing with this for loop and store this values as K_2. what i am trying to implement is a non recursive phasor estimate.
for k = 0:5
for i = 0+k:11+k
K( =(sqrt(2)/N)*(100*cos(i*Theta + (pi/4 + (k*Theta)).*exp(-j*i*Theta)))
X_N(k+1,:) = [K]
end
end
Thanks before hand

Respuestas (2)

Walter Roberson
Walter Roberson el 7 de Mzo. de 2013
X_N(k+1,i) = K;

Image Analyst
Image Analyst el 7 de Mzo. de 2013
Perhaps this?
N = 3; % Whatever...
Theta = pi/42; % Whatever...
X_N = zeros(6, 12); % Initialize
for k = 0:5
i = k:(11+k);
K =(sqrt(2)/N)*(100*cos(i*Theta + (pi/4 + (k*Theta)).*exp(-j*i*Theta)));
X_N(k+1,:) = K;
end

Community Treasure Hunt

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

Start Hunting!

Translated by