I have a power spectrum for my model. I would like to add sine wave as a drive with power spectrum. I don't know how to calculate the power of sine wave? Can I add the sine wave with power? Can anyone help me, please?

 Réponse acceptée

Rishabh Rathore
Rishabh Rathore le 28 Mai 2018
Modifié(e) : Rishabh Rathore le 28 Mai 2018

0 votes

Here's what I understand from your question, you want to know how to calculate 'Power' of sine wave and plot it over Power Spectrum of your model.
Power of the sine wave A*sin(x), is (A^2)/2, but only when A is constant. If the amplitude is varying, then integrate the wave over one time period and divide it by the time period to get the power.
You can then use this to add/plot the corresponding value on the Power spectrum of your model.
To plot the power of Sine wave over the existing plot, use hold on and hold of.
Refer this link for more information on Hold.

4 commentaires

Namira
Namira le 28 Mai 2018
Thanks. My function is drive = A*sin(2*pi*f*t); I would like to add the signal in frequency domain. Should I square the amplitude after fft or before fft?
Rishabh Rathore
Rishabh Rathore le 28 Mai 2018
fft itself calculates the power spectrum of the wave. So, applying fft will itself give the power of the wave. For your sine wave, it should give level 'A' at f.
Namira
Namira le 28 Mai 2018
Thanks. I found this code in Matlab to calculate Power Spectral Density Estimates Using FFT. I am a little bit confused why the signal is squared after fft?
rng default
Fs = 1000;
t = 0:1/Fs:1-1/Fs;
x = cos(2*pi*100*t) + randn(size(t));
N = length(x);
xdft = fft(x);
xdft = xdft(1:N/2+1);
psdx = (1/(Fs*N)) * abs(xdft).^2;
psdx(2:end-1) = 2*psdx(2:end-1);
freq = 0:Fs/length(x):Fs/2;
plot(freq,10*log10(psdx))
grid on
title('Periodogram Using FFT')
xlabel('Frequency (Hz)')
ylabel('Power/Frequency (dB/Hz)')
it is because of the line
psdx = (1/(Fs*N)) * abs(xdft).^2;
The absolute value is squared.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by