Assign loop values into each rows

5 views (last 30 days)
Yuling CAO
Yuling CAO on 19 Sep 2016
Edited: Andrei Bobrov on 19 Sep 2016
Hi, I built a loop and want to assign each H12 and H34 result when i=1:600 into each rows? Can someone give me a code?
tsteps = 600; % timesteps
for i = 1:tsteps
% calculate autospectra
sp11 = conj(p1(i,:)).*p1(i,:);
sp33 = conj(p3(i,:)).*p3(i,:);
% calculate cross spectrum.
sp12 = conj(p1(i,:)).*p2(i,:);
sp34 = conj(p3(i,:)).*p4(i,:);
% calculate transfer function
H12 = sp11(i)./sp12(i);
H34 = sp33(i)./sp34(i);
end

Answers (1)

Andrei Bobrov
Andrei Bobrov on 19 Sep 2016
sp11 = conj(p1).*p1;
sp33 = conj(p3).*p3;
sp12 = conj(p1).*p2;
sp34 = conj().*p4;
H12 = sp11./sp12;
H34 = sp33./sp34;

Tags

Community Treasure Hunt

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

Start Hunting!