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 h in 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
thanks for your efforts. This is actually algorithm for adding phase noise in a signal. after that i want to add h in the signal S, so i get the phase noise. However when make the new signal using S1 and try to analyze the signal in frequency domain. its showing matrix mistach.
S1 = cos(2*pi*fc*t + h); L = length(S1); nfft = L*100; %%%%%% Zero padding res = fft(S1,nfft)/nfft; % resize into nfft nr of element % normalize the amplitude f = fs/2*linspace(0,1,nfft/2+1); res = res(1:nfft/2+1); figure, plot(f,abs(res)); % figure, plot(f,angle(res)); return