help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: amplitude axis of frequency domain plot not matching question tia sa


From: Rick T
Subject: Re: amplitude axis of frequency domain plot not matching question tia sal22
Date: Wed, 9 Mar 2011 13:44:11 -1000

no the 8 is amplitude http://en.wikipedia.org/wiki/Sine_wave

but the graph says 30+ here's an image of the plot look at the bottom plot
http://dl.dropbox.com/u/6576402/freq_domain_plot.png

tia sal22



On Wed, Mar 9, 2011 at 1:33 PM, Doug Stewart <address@hidden> wrote:


On Wed, Mar 9, 2011 at 5:46 PM, Rick T <address@hidden> wrote:
Greetings all 

I have a frequency domain plot that plots but the amplitude doesn't match 
the equation at all.  In the example I have the amplitude set to 8 but when I plot it the amplitude
shows up as 30+ why is this?

tia sal22

code below:
Fs = 1000;                    % Sampling frequency
t=linspace(0,1,1000);
vp_sig_orig=8*sin(2*pi*2*t)
vp_sig_len=length(vp_sig_orig); 


% Use next highest power of 2 greater than or equal to length(x) to calculate FFT.
nfft= 2^(nextpow2(length(vp_sig_orig))); 

% Take fft, padding with zeros so that length(fftx) is equal to nfft 
fftx = fft(vp_sig_orig,nfft); 

% Calculate the numberof unique points
NumUniquePts = ceil((nfft+1)/2); 

% FFT is symmetric, throw away second half 
fftx = fftx(1:NumUniquePts); 

% Take the magnitude of fft of x and scale the fft so that it is not a function of the length of x
mx = abs(fftx)/length(vp_sig_orig); 

% Take the square of the magnitude of fft of x. 
mx = mx.^2; 

% Since we dropped half the FFT, we multiply mx by 2 to keep the same energy.
% The DC component and Nyquist component, if it exists, are unique and should not be multiplied by 2.
if rem(nfft, 2) % odd nfft excludes Nyquist point
  mx(2:end) = mx(2:end)*2;
else
  mx(2:end -1) = mx(2:end -1)*2;
end

% This is an evenly spaced frequency vector with NumUniquePts points. 
freq_vect = (0:NumUniquePts-1)*vp_sig_len/nfft; 


% Generate the plot, title and labels. 
subplot(2,1,1),plot(t,vp_sig_orig)
title('Time domain plot'); 
xlabel('time'); 
ylabel('Power'); 

plot_len=1000;%length to plot
subplot(2,1,2), plot(freq_vect(1:end),mx(1:end))
title('Power Spectrum of vp'); 
xlabel('Frequency (Hz)'); 
ylabel('Power'); 




_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave

In the next line you talk about energy
% Since we dropped half the FFT, we multiply mx by 2 to keep the same energy. 

vp_sig_orig=8*sin(2*pi*2*t)
Do you think that 8 is energy?

Doug





reply via email to

[Prev in Thread] Current Thread [Next in Thread]