for loops iterations into array

3 次查看(过去 30 天)
Christopher
Christopher 2013-3-7
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

回答(2 个)

Walter Roberson
Walter Roberson 2013-3-7
X_N(k+1,i) = K;

Image Analyst
Image Analyst 2013-3-7
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

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by