sine wave with noise
4 views (last 30 days)
Show older comments
Hi all
I have sine signal with noise where the number of points of noise per oscillation should be the same say five points per oscillation) , I want to change each time the number of oscillation :2,3,4….15
At each number of oscillation I shall extract the amplitude as a function of frequency < unfortunately for few oscillation FFT wouldn't work there are too few points in the signal
So how can I do that ?
See my attach code
num=50;
Fs=1000; %sampling frequency
Ts=1/Fs; %sampling period or time
dt=0:Ts:1-Ts; %signal duration
f=100;
num_points_osc=Fs/f; % number of points per oscillation
y1=sin(2*pi*f*dt);
y2=randn(1,num);
y=y1(num)+y2;
nfft=length(y);%length of time domain signal
nfft2=2^nextpow2(nfft);%length of signal in power 2 - since it's more effecient for fft in matlab
ff=fft(y,nfft2);
fff=ff(1:nfft2/2);
fff=fff/max(fff);
xfft=Fs*(0:nfft2/2-1)/nfft2;
absfff=abs(fff);
figure
subplot(2,1,1);
plot(dt(1:num),y2,'.g','markersize',15);
hold on
plot(dt(1:num),y1(1:num));
xlabel('Time [s]');
ylabel('Amplitude [v]')
title('Time Domain signal ');
subplot(2,1,2)
plot(xfft,absfff,'.-r','markersize',12);
xlabel('Frequency [Hz]');
ylabel('Normailzed Amplitude')
title('Frequency Signal Domain')
0 Comments
Answers (0)
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!