Re: MATLAB code for Power Spectral Density




"Mike Yarwood" <mpyarwood@xxxxxxxxxxxxxxx> wrote in message
news:dnet0d$d1k$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> "john" <johns@xxxxxxxxxx> wrote in message
> news:1134210735.813800.60750@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> >
> > ngeva0 wrote:
> >> Can anyone please check if my code is correct? SINE512 is just a file
> >> name.
> >> This file has 512 data points and it's a sine wave. Thank you!!
> >>
> >> %Sampling frequency
> >> Fs=50000;
> >>
> >> %# of samples in the data
> >> datasize=size(SINE512);
> >> numsample=datasize(1);
> >>
> >> %Windowing
> >> H=hann(numsample);
> >> W=H.*(SINE512(:,2));
> >>
> >> %Fourier Transform
> >> FFTX=fft(W,numsample);
> >>
> >> %Power: magnitude^2
> >> X=FFTX(1:floor(numsample/2)).*conj(FFTX(1:floor(numsample/2)));
> >>
> >> %Bandwidth
> >> BW=1.5*Fs*numsample;
> >>
> >> %PSD=magnitude^2/bandwidth
> >> PSD=X/BW;
> >>
> >> %Computing the corresponding frequency values
> >> Omega=Fs*(0:numsample-1)/numsample;
> >> Omega=Omega(1:floor(numsample/2));
> >>
> >> %Plot PSD
> >> H=plot(Omega,PSD);
> >> set(H,'Color','BLACK');
> >
> > I am happy to report that your code behaves exactly as programmed.
> > Congratulations.
> >
> But you may want to look at :
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fft.html#998360
>
> where you can see that they normalise power in the bin by dividing by the
> number of points in the DFT and get powers of about 2*pi for their unit
> peak amplitude sinewaves.
>
> A 1Volt peak amplitude sinewave across a 1 ohm resistor dissipates 1/2
watt
> and your PSD display may either register a 1 volt (peak) input sinewave as
0
> dBV (w.r.t. 1V pk), -3.01 dBV (w.r.t. 1 V r.m.s) or -6.02 dBV (w.r.t. 1
> Vpk-pk but this is very unlikely). So put a known amplitude sinewave into
> your instrument (with as little extra noise as possible) and see what it
> displays.
>
> None of the above? has it scaled by a further 10*log10(512/50000) ~ -19.9
> dB ?
>
> Now you know what the instrument is doing you can decide what your matlab
> routine should do.
>
>
> Best of Luck - Mike
>
>
Remember its the AREA under the PSD that gives power - not the peak values.
For a sine wave on a bin this means you need to multiply by the width of the
bin.

Glen


.



Relevant Pages

  • Re: Collins 32V-3 HF Transmitter NICE!!!
    ... I think Gary Schafer's analysis is basically correct but I have minor comments to add (in addition to my earlier post, also quoted below, claiming the 400+ peak output just could not be possible, but I think I was wrong about that). ... 60 watts of audio on that final tube will at best, double the _instantaneous_ input voltage, therefore power to 240 watts which you could only attempt to measure ... amplitude, the power at this instant is four times the unmodulated, or 400 ...
    (rec.radio.amateur.boatanchors)
  • Re: Collins 32V-3 HF Transmitter NICE!!!
    ... Re-read the deffinition of PEP which you deleted. ... It is all average power. ... Forget about peak power. ... the very peak of the voltage and current. ...
    (rec.radio.amateur.boatanchors)
  • Re: Collins 32V-3 HF Transmitter NICE!!!
    ... >> Keep in mind when trying to understand PEP that there is no peak power ... It is all average power. ... Forget about peak power. ... the very peak of the voltage and current. ...
    (rec.radio.amateur.boatanchors)
  • Re: SPDIF to Analog converter.
    ... the Wattage is a big fat lie!.. ... to handle that peak power without drawing that same amount of power from ... average power to the speakers remaining below 5 watts. ... my only point is the peak power output of any system can be a lot ...
    (sci.electronics.repair)
  • Re: Politicians and energy policy
    ... can be plugged into the power grid and charged at night when the power ... for peak usage and non-peak usage. ... I don't see how the "smart" load controls can do a good job. ...
    (sci.electronics.design)