troble in applying for loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Kutru biladi
am 28 Jul. 2015
Kommentiert: Kutru biladi
am 28 Jul. 2015
I want to apply for loop. Below is my code. I have applied the for loop which is wrong. Here Length(t) is sample numbers. Here I want to create 'for' loop for a sample number 5 in particular. so how to change the for loop. Moreover, 'phi_sync' shoud be sample number of 5 and 'phi_acc' shoud be summation from 0 to 5 sample numbers.
fs = 200;
ts = 1/fs;
t = 0:ts:1-ts;
fc = 50;
S = cos(2*pi*fc*t); % equation 7.1 noisless
sigma = 1.8;
phi_sync = sigma * randn(1,length(t)); % random variable with gaussian distributed
phi_acc = sigma * randn(1,length(t)); % random variable with gaussian distributed
% h = 0;
for i=1:length(S)
h = phi_sync + phi_acc(i);
end
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 28 Jul. 2015
Bearbeitet: Azzi Abdelmalek
am 28 Jul. 2015
k=0
h=zeros(size(1:5:numel(S)))
for ii=1:5:numel(S)
k=k+1
h(k)= phi_sync(ii) + phi_acc(ii);
end
7 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!