for loops iterations into array

조회 수: 1 (최근 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에서 Direction of Arrival Estimation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by