how can i plot a power spectrum for my signal?
Mostra commenti meno recenti
i generated three signal of frequency 1hz, 2hz and 3 hz. added these three signal. how to plot power spectrum for the added signal?
N=1024;
fs=1000;
f=1;
ts=1/fs;
t = ts*(0:N-1);
x=sin(2*pi*f*t);
subplot(2,3,1)
plot(t,x)
title('1hz');
f1=2;
x1=sin(2*pi*f1*t);
subplot(2,3,2)
plot(t,x1)
title('2hz');
f2=3;
x2=sin(2*pi*f2*t);
subplot(2,3,3)
plot(t,x2)
title('3hz');
x3=x+x1+x2;
subplot(2,3,4)
plot(t,x3)
title('added freq signal');
Risposta accettata
Più risposte (1)
Bhaskar R
il 16 Nov 2019
It is from the reference
N=1024;
fs=1000;
% signal 1Hz
f=1;
ts=1/fs;
t = ts*(0:N-1);
x=sin(2*pi*f*t);
subplot(4,2,1),plot(t,x),title('1hz');
% power spectrum of 1 Hz
y = fft(x);
N = length(x); % number of samples
f = (0:N-1)*(fs/N); % frequency range
pow = abs(y).^2/N; % power of the DFT
subplot(4,2,2),plot(f,pow), title('1hz power');
% signal 2Hz
f1=2;
x1=sin(2*pi*f1*t);
subplot(4,2,3),plot(t,x1),title('2hz');
% power spectrum of 3 Hz
y = fft(x1);
N = length(x); % number of samples
f = (0:N-1)*(fs/N); % frequency range
pow = abs(y).^2/N; % power of the DFT
subplot(4,2,4),plot(f,pow), title('2hz power');
% signal 3Hz
f2=3;
x2=sin(2*pi*f2*t);
subplot(4,2,5),plot(t,x2),title('3hz');
% power spectrum of 3 Hz
y = fft(x2);
N = length(x); % number of samples
f = (0:N-1)*(fs/N); % frequency range
pow = abs(y).^2/N; % power of the DFT
subplot(4,2,6),plot(f,pow), title('3hz power');
% signal combined Hz
x3=x+x1+x2;
subplot(4,2,7),plot(t,x3),title('added freq signal');
% power spectrum of combined Hz
y = fft(x3);
N = length(x); % number of samples
f = (0:N-1)*(fs/N); % frequency range
pow = abs(y).^2/N; % power of the DFT
subplot(4,2,8),plot(f,pow), title('combine hz power');
1 Commento
prajith samraj
il 19 Apr 2022
how to plot nonlinear differntial equation of van der pol oscilator or mlc oscillator?
Categorie
Scopri di più su Fourier Analysis and Filtering in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!