Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %%task3
- clc
- close all
- clear all
- load('task3.mat')
- %% Values
- N=2048;
- t1=1/fs;
- x1=x;
- x2=x(1:2048);
- df1=fs/length(x1);
- df2=fs/N;
- f1=0:df1:fs-df1;
- f2=0:fs/N:fs-fs/N;
- %% From newton signal to transient spectre
- % N=16384
- xf1=fft(x1);
- xfpower1=abs(xf1);
- xfpower1=xfpower1.^2;
- Scale1=2*(t1.^2);
- xfenergy1=xfpower1*Scale1; %Esd
- xfenergy1(1)=xfenergy1(1)/2; % as the factor two shouldnt be added for gxx(0) as stated in the lecture notes because of properly scaled DC value
- transient=sqrt(xfenergy1);
- %N=2048
- xf2=fft(x2);
- xfpower2=xf2;
- xfpower2=xfpower2.^2;
- Scale2=2*t1.^2;
- xfenergy2=xfpower2*Scale2; %Esd
- xfenergy2(1)=xfenergy2(1)/2; % as the factor two shouldnt be added for gxx(0) as stated in the lecture notes because of properly scaled DC value
- transient2=sqrt(xfenergy2);
- %% Plots
- plot(f1,abs(transient),'k')
- hold on
- plot(f2,abs(transient2),'r');
- title('trancient spectra')
- xlabel('frequency[k]');
- ylabel('Ns');
- legend('Original signal','block length(N=2048)')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement