Originally Posted by
qwerty321 Hello
can someone help me with this assignement?
Find in MATLAB the frequency components in the following
signal:
y
(t) = (cos(300πt) + sin(500πt))3
Use
.^3 (with the dot) in MATLAB to calculate the third power.
how do I do this?
thank you
try 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
This is not normalised (since the normalisation is different for different FFT implementations). It also gives an absolute amplitude plot. I would prefere a dB plot re arbitary myself.