필터 지우기
필터 지우기

how can i plot a power spectrum for my signal?

조회 수: 221 (최근 30일)
srividhya s
srividhya s 2019년 11월 16일
댓글: prajith samraj 2022년 4월 19일
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');

채택된 답변

Frantz Bouchereau
Frantz Bouchereau 2021년 7월 29일
There are various ways in which you can compute and plot true power spectrum or power spectral density in MATLAB (when I say 'true power spectrum' I mean that the output values correspond to actual power values).
1) If you want to compute the power spectrum without having to specify many parameters and want the function to choose the best parameters for you, you can use pspectrum. Calling the function without outputs will give you a plot with the computed power spectrum.
2) If you want to compute power spectrum or power spectral density and want full control over the window size, window overlap, window type, and number of FFT points, you can use the Welch periodogram pwelch function. Calling the function without outputs will give you a plot with the computed power spectrum.
3) If you want to just visualize the power spectrum, you can use the Signal Analyzer app. The app let's you visualize your signals simultaneously in the time, frequency, and time-frequency domains. You can zoom into signal regions of interest and analyze the spectra at those zoomed regions.
4) If you have split your signals into multiple signal frames you can use the Spectrum Analyzer scope.
Finally, here is a popular MATLAB doc page that explains the relationship between FFT and true power spectra: Power Spectral Density Estimates Using FFT.

추가 답변 (1개)

Bhaskar R
Bhaskar R 2019년 11월 16일
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
prajith samraj
prajith samraj 2022년 4월 19일
how to plot nonlinear differntial equation of van der pol oscilator or mlc oscillator?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by