| Author |
Message |
seadolphine2000
Joined: 12 Apr 2005 Posts: 563 Helped: 31
|
28 Mar 2006 21:38 MATLAB simulation question. |
|
|
|
I want to make Fourier Trasnform to a continous signal and then plot the spectrum of this signal. Does anyone know how can I do it.????
I tried to use the FFT command for a simple function (sinx) but it gives wrong results.
Any help will be appreciated. Thanks
|
|
| Back to top |
|
 |
mimomod
Joined: 25 Jan 2006 Posts: 110 Helped: 15
|
28 Mar 2006 22:02 MATLAB simulation question. |
|
|
|
Hi,
i think it is not possible to define a continuous signal in matlab since matlab only dealing with discrete-time signal. Nevertheless you may substitute the continuous signal ith a "pseudo" continuous signal which is a discrete-time signal with a very high frequency sampling (e.g. 10 times as the Nyquist frequency).
Consequency, when you plot the spectrum of sinx based on its "pseudo" representation, you will not get just an impulse at -f and +f, but you will get two dominant (higher magnitude) pulses at -f and +f and many side-lobes (less magnitude). When the sampling frequency of the "pseudo" continuous signal gets higher, then the pulses get closer to impulses and the side-lobes get vanished.
best
|
|
| Back to top |
|
 |
Sal
Joined: 29 Nov 2005 Posts: 291 Helped: 36
|
28 Mar 2006 23:10 MATLAB simulation question. |
|
|
|
HI it is possible if you have the Symbolic Toolbox
syms y x
y = sin(x);
Y = fourier(y);
ezplot(Y)
viola
Sal
|
|
| Back to top |
|
 |
mimomod
Joined: 25 Jan 2006 Posts: 110 Helped: 15
|
29 Mar 2006 11:17 MATLAB simulation question. |
|
|
|
Yes if you have the symbolic toolbox, but seadolphine2000 did the Fourier analysis using FFT function, which is not symbolic.
best
|
|
| Back to top |
|
 |
magnetra
Joined: 21 Apr 2005 Posts: 264 Helped: 3 Location: 27.45N, 85.20E KTM, NP
|
|
| Back to top |
|
 |
seadolphine2000
Joined: 12 Apr 2005 Posts: 563 Helped: 31
|
30 Mar 2006 23:27 Re: MATLAB simulation question. |
|
|
|
Viola wrote:
| Quote: |
HI it is possible if you have the Symbolic Toolbox
syms y x
y = sin(x);
Y = fourier(y);
ezplot(Y) |
Thanks to your help but,...
I've tried this code and it gives me errors.
What shall I do now.?
|
|
| Back to top |
|
 |
matchasm
Joined: 14 Mar 2006 Posts: 23
|
31 Mar 2006 2:39 Re: MATLAB simulation question. |
|
|
|
| seadolphine2000 wrote: |
| What shall I do now.? |
Assuming you don't know too much about Matlab, try "doc fft" in the command window. It gives you this nice little example:
**********
Examples
A common use of Fourier transforms is to find the frequency components of a signal buried in a noisy time domain signal. Consider data sampled at 1000 Hz. Form a signal containing 50 Hz and 120 Hz and corrupt it with some zero-mean random noise:
| Code: |
t = 0:0.001:0.6;
x = sin(2*pi*50*t)+sin(2*pi*120*t);
y = x + 2*randn(size(t));
plot(1000*t(1:50),y(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('time (milliseconds)') |
It is difficult to identify the frequency components by looking at the original signal. Converting to the frequency domain, the discrete Fourier transform of the noisy signal y is found by taking the 512-point fast Fourier transform (FFT):
The power spectrum, a measurement of the power at various frequencies, is
| Code: |
| Pyy = Y.* conj(Y) / 512; |
Graph the first 257 points (the other 255 points are redundant) on a meaningful frequency axis:
| Code: |
f = 1000*(0:256)/512;
plot(f,Pyy(1:257))
title('Frequency content of y')
xlabel('frequency (Hz)') |
This represents the frequency content of y in the range from DC up to and including the Nyquist frequency. (The signal produces the strong peaks.)
|
|
| Back to top |
|
 |
seadolphine2000
Joined: 12 Apr 2005 Posts: 563 Helped: 31
|
01 Apr 2006 0:44 MATLAB simulation question. |
|
|
|
| I've tried this code before, but it didn't give me the expected results.
|
|
| Back to top |
|
 |
davyzhu
Joined: 23 May 2004 Posts: 530 Helped: 3 Location: oriental
|
01 Apr 2006 3:42 MATLAB simulation question. |
|
|
|
Hi,
I recommend the code from:
http://www.billauer.co.il/easyspec.html
Tell me if the code is right, thanks!
Regards,
Davy
|
|
| Back to top |
|
 |