Thread Subject: simulink fft of sinewave

Subject: simulink fft of sinewave

From: Tc Simons

Date: 13 Nov, 2009 03:42:03

Message: 1 of 8

Hi I am having problems getting the frequency spectrum of a sine wave in simulink.

The system I have designed is fairly basic. The signal is a 5hz sine wave that gets outputed to a scope and a Zero-Order Hold. From there it goes to the Spectrum Scope and a vector scope.

Both the scope and vector scope show the same 5hz wave. The spectrum of a 5hz wave should show a single spike at 5hz (using stems), but this is not the case. I get one spike at ~4.8 and another at ~5.3

Can anyone help with this? I am at a lose for what to do next.

Thanks
Tc

Subject: simulink fft of sinewave

From: Tc Simons

Date: 13 Nov, 2009 04:06:03

Message: 2 of 8

The zero-hold is set to .01
The run time is 30.
Also I zoomed out further on my freq plot and I am actually getting the spikes at ~4.8 & ~5.3 but also at ~94.8 & ~95.3

The sine wave is setup at:
Amplitude 2
Freq 5

Thanks
Tc

"Tc Simons" <tcsimons@ualr.edu> wrote in message <hdikib$fcc$1@fred.mathworks.com>...
> Hi I am having problems getting the frequency spectrum of a sine wave in simulink.
>
> The system I have designed is fairly basic. The signal is a 5hz sine wave that gets outputed to a scope and a Zero-Order Hold. From there it goes to the Spectrum Scope and a vector scope.
>
> Both the scope and vector scope show the same 5hz wave. The spectrum of a 5hz wave should show a single spike at 5hz (using stems), but this is not the case. I get one spike at ~4.8 and another at ~5.3
>
> Can anyone help with this? I am at a lose for what to do next.
>
> Thanks
> Tc

Subject: simulink fft of sinewave

From: Ashwini Deshpande

Date: 13 Nov, 2009 04:43:02

Message: 3 of 8

"Tc Simons" <tcsimons@ualr.edu> wrote in message <hdilvb$cap$1@fred.mathworks.com>...
> The zero-hold is set to .01
> The run time is 30.
> Also I zoomed out further on my freq plot and I am actually getting the spikes at ~4.8 & ~5.3 but also at ~94.8 & ~95.3
>
> The sine wave is setup at:
> Amplitude 2
> Freq 5
>
> Thanks
> Tc
>
> "Tc Simons" <tcsimons@ualr.edu> wrote in message <hdikib$fcc$1@fred.mathworks.com>...
> > Hi I am having problems getting the frequency spectrum of a sine wave in simulink.
> >
> > The system I have designed is fairly basic. The signal is a 5hz sine wave that gets outputed to a scope and a Zero-Order Hold. From there it goes to the Spectrum Scope and a vector scope.
> >
> > Both the scope and vector scope show the same 5hz wave. The spectrum of a 5hz wave should show a single spike at 5hz (using stems), but this is not the case. I get one spike at ~4.8 and another at ~5.3
> >
> > Can anyone help with this? I am at a lose for what to do next.
> >
> > Thanks
> > Tc

I tried the same, but i am getting peak at 5Hz nowhere else. Can u tell me what are the parameters of ur sine wave and fft spectrum block.

Ashwini

Subject: simulink fft of sinewave

From: Tc Simons

Date: 13 Nov, 2009 05:03:22

Message: 4 of 8

"Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in message <hdio4m$oom$1@fred.mathworks.com>...
> "Tc Simons" <tcsimons@ualr.edu> wrote in message <hdilvb$cap$1@fred.mathworks.com>...
> > The zero-hold is set to .01
> > The run time is 30.
> > Also I zoomed out further on my freq plot and I am actually getting the spikes at ~4.8 & ~5.3 but also at ~94.8 & ~95.3
> >
> > The sine wave is setup at:
> > Amplitude 2
> > Freq 5
> >
> > Thanks
> > Tc
> >
> > "Tc Simons" <tcsimons@ualr.edu> wrote in message <hdikib$fcc$1@fred.mathworks.com>...
> > > Hi I am having problems getting the frequency spectrum of a sine wave in simulink.
> > >
> > > The system I have designed is fairly basic. The signal is a 5hz sine wave that gets outputed to a scope and a Zero-Order Hold. From there it goes to the Spectrum Scope and a vector scope.
> > >
> > > Both the scope and vector scope show the same 5hz wave. The spectrum of a 5hz wave should show a single spike at 5hz (using stems), but this is not the case. I get one spike at ~4.8 and another at ~5.3
> > >
> > > Can anyone help with this? I am at a lose for what to do next.
> > >
> > > Thanks
> > > Tc
>
> I tried the same, but i am getting peak at 5Hz nowhere else. Can u tell me what are the parameters of ur sine wave and fft spectrum block.
>
> Ashwini

SINE WAVE
====================================
Sine type: Time based
Time (t): Use simulation Time
Amplitude: 2
Bias: 0
Frequency (rad/sec): 31.41592649995191
Phase: pi/2
Sample time: 0
Interpret vector parameters as 1-D: Checked

FFT SPECTRUM BLOCK
=====================================
Buffer input: checked
Buffer size: 128
Buffer overlap: 64
Window type: Hann
Window sampling: Periodic
Specify FFT Length: Unchecked
Number of spectral averages: 2


I can email you my file if that would be more helpful.

Thanks
Tc

Subject: simulink fft of sinewave

From: Ashwini Deshpande

Date: 13 Nov, 2009 06:42:07

Message: 5 of 8

> SINE WAVE
> ====================================
> Sine type: Time based
> Time (t): Use simulation Time
> Amplitude: 2
> Bias: 0
> Frequency (rad/sec): 31.41592649995191
> Phase: pi/2
> Sample time: 0
> Interpret vector parameters as 1-D: Checked
>
>
> =====================================
> Buffer input: checked
>
> Buffer overlap: 64
> Window type: Hann
> Window sampling: Periodic
>
> Number of spectral averages: 2
>
>
> I can email you my file if that would be more helpful.

Try changing the FFT SPECTRUM BLOCK parameters to:
Buffer size: 1024
Specify FFT Length: checked (1024)

if it does not help u, then mail me ur model.
-- Ashwini

Subject: simulink fft of sinewave

From: Tc Simons

Date: 13 Nov, 2009 08:18:01

Message: 6 of 8

> Try changing the FFT SPECTRUM BLOCK parameters to:
> Buffer size: 1024
> Specify FFT Length: checked (1024)
>
> if it does not help u, then mail me ur model.
> -- Ashwini

I sent you and email to your yahoo account with the file. Your suggestion made the plot with no markers selected spike at 5hz like it is supposed but with stem on it still is producing three spikes around 5hz but the same spike is still at 95hz as well, which I am unsure why?

Thank you again for all your help
Tc

Subject: simulink fft of sinewave

From: Ashwini Deshpande

Date: 13 Nov, 2009 09:56:04

Message: 7 of 8

"Tc Simons" <tcsimons@ualr.edu> wrote in message <hdj4np$dmf$1@fred.mathworks.com>...
> > Try changing the FFT SPECTRUM BLOCK parameters to:
> > Buffer size: 1024
> > Specify FFT Length: checked (1024)
> >
> > if it does not help u, then mail me ur model.
> > -- Ashwini
>
> I sent you and email to your yahoo account with the file. Your suggestion made the plot with no markers selected spike at 5hz like it is supposed but with stem on it still is producing three spikes around 5hz but the same spike is still at 95hz as well, which I am unsure why?
>
> Thank you again for all your help
> Tc

I have replied to your mail. check it out.
And follow the link below, which will clear all your doubts.
Here is the link:
http://www.ele.uri.edu/~hansenj/projects/ele436/fft.pdf

HTH,
Ashwini

Subject: simulink fft of sinewave

From: Tc Simons

Date: 16 Nov, 2009 04:18:01

Message: 8 of 8

Ok now I see how it works in simulink. After that starting working I modified the setup and now in simulink I have a sinewave generator that sends it's data back to the workspace. In matlab I am now trying to do the fft here and encountering another problem. The sinewave is 5hz but when I stem plot the fft in mathlab the spike is now at11hz instead of 5hz.

simulink:
I setup the waveform in simulink then send it to the workspace.

In matlab:
aa = abs(fft(wave1));
stem (aa);

I am unsure what needs to be changed to fix this issue.

Thanks
tc

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
simulink Tc Simons 12 Nov, 2009 22:44:04
spectrum scope Tc Simons 12 Nov, 2009 22:44:04
stem Tc Simons 12 Nov, 2009 22:44:04
rssFeed for this Thread

Contact us at files@mathworks.com