dsa

Printable View

- January 12th 2009, 02:44 AMqwerty321matlab fft
dsa

- January 12th 2009, 05:28 AMConstatine11try this:

Code:fs=2000; %sampling frequency

dt=1/fs; %sampling interval

t=0:dt:1-dt/2;

y=(cos(300*pi*t)+cos(500*pi*t)).^3; %1 seconds worth ofsignal

sp=fft(y); %fft

spp=abs(sp); %absolute value of frequency component

%(you could square this as well to get something like a power)

df=1; %frequency resolution (in Hz)

f=0:df:999; %frequency scale for spectrum

spp=spp(1:1000); %cut out the part of spectrum below Nyquist frequenct

plot(f,spp); %plot

- January 12th 2009, 08:15 AMqwerty321
ok..someone told me I could also use this:

Y = fft(y,512);xlabel('frequency (Hz)')

Pyy = Y.* conj(Y)/512;

f = 20000*(0:256)/512;

plot(f,Pyy(1:257))

title('Frequency content of y')

can you expalin to me what each one does?

y is a function

- January 12th 2009, 11:34 AMConstatine11
- January 13th 2009, 04:58 AMqwerty321
well in fact this code was use to find the frequency components of a signal buried inside a noisy time domain signal using the fft function in MATLAB.

the assignement says :

Using the same technique, find in MATLAB the frequency components in the following

signal:*y*(*t*) = (cos(300π*t*) + sin(500π*t*))^3

so i think i need to use the same code

thank you

- January 13th 2009, 05:24 AMqwerty321
ur code does not work anyhow

Undefined function or variable 'dt'.

why? - January 13th 2009, 05:35 AMqwerty321
btw is there a command that can clear the command window?becauase each time i want to write something new i have to exit then reenter it

- January 13th 2009, 06:11 AMConstatine11