for loop storing the same variable
Show older comments
I have a for loop as below:
I is intensity of length 1000 (constant)
noise is a random white noise of length 1000
demodulated_power_vector1=zeros(floor(length(I)/4),4);
demodulated_power_vector2=zeros(floor(length(I)/4),4);
demodulated_power_vector3=zeros(floor(length(I)/4),4);
demodulated_power_vector4=zeros(floor(length(I)/4),4);
for ii=0:floor(length(I)/4)
for ss= 0:floor(length(noise)/4)
demodulated_power_vector1(:,1)=(I(1+ii)/2)*(1+cos(Dphi+noise(1+ss)+pi-alphaa));
demodulated_power_vector2(:,2)=(I(2+ii)/2)*(1+cos(Dphi+noise(2+ss)+pi+alphaa));
demodulated_power_vector3(:,3)=(I(3+ii)/2)*(1+cos(Dphi+noise(3+ss)-pi+alphaa));
demodulated_power_vector4(:,4)=(I(4+ii)/2)*(1+cos(Dphi+noise(4+ss)-pi-alphaa));
end
end
Why is the for loop storing the same variable? I'm getting the same answer. for example, the 250 variables stored in demodulated_power_vector1 are the same.
I dont know what i'm doing wrong. Kindly assist.
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!