Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear;clc;
- %% generate x-axe
- first_step=0;
- step_t=0.01;
- last_step=1;
- t=first_step:step_t:last_step;
- %% signal and fourier transform
- y= 2*sin(2*pi*60*t) ;
- figure(1)
- plot(t,y);title('signal')
- fourier=fft(y );
- N_=length(fourier);
- f_ = (1 / step_t) * ( 0: (N_/2) ) / N_;
- a=(fourier.*conj(fourier))/(N_*N_); % Spectral Density get half
- a = a(1:N_ /2+1);
- a(2:end-1) = 4*a(2:end-1);
- figure(2);
- plot(f_,a);title('Spectrum Power through signal');
- %% through AutoCorrelation function
- tau=0.01;
- y1= 2*sin(2*pi*60*(t+tau)) ;
- Y=y1.*y;
- AutoCorr_func = cumtrapz(Y,t);
- figure(3);
- plot(t,AutoCorr_func); title('AutoCorrelation function');
- fourier=fft(AutoCorr_func);
- N_=length(fourier);
- f_ = (1 / step_t) * ( 0: (N_/2) ) / N_;
- a=fourier.*conj(fourier) ; % Spectral Density
- a = a(1:N_ /2+1); % spectrum is even, so get half
- a(2:end-1) = a(2:end-1); % multiply by 4, since spectrum is square of amplitude, and we have two even halves
- figure(4)
- plot(f_ ,a );
- title('Spectrum through AutoCorrelation funciton');
- Y=y1.*y;
- AutoCorr_func = cumtrapz(Y,t);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement