Fourier Transform

hey guys i am kinda new to matlab, and would really appreciate it if you guys help me thanx so much
Generate the following function
y1(t)=2*sin(2*pi*1*t)+4*sin(2*pi*2*t)+3*sin(2*pi*4*t)
y2(t)=2*cos(2*pi*1*t)+4*cos(2*pi*2*t)+3*cos(2*pi*4*t)
First, required by sampling theorem, the step size of t (delta t) has to be smaller than a value. Figure out this value and set the delta t at least 3 times smaller than this value and calculated y1(t) and y2(t). Increase the step size and recalculate y1(t) and y2(t). See the difference.
Calculate Fourier Transform of y1(t) and y2(t) using ‘fft’ and plot your results. Using frequency as the x axis data and amplitude as the y axis data. Also, plot the phase, too.
f=[0:1/length(y1):1/2]*(1/delta_t)
figure; plot(f, abs(y1(1:length(f))), -*)
Use function of ‘abs’ to calculate the amplitude and ‘angle’ to calculate phase.

3 个评论

doc fft
zaini
zaini 2011-2-21
please use code writing mode, to make it more readable
y1(t)=2*sin(2*pi*1*t)+4*sin(2*pi*2*t)+3*sin(2*pi*4*t)
y2(t)=2*cos(2*pi*1*t)+4*cos(2*pi*2*t)+3*cos(2*pi*4*t)
does this make it better?

请先登录,再进行评论。

回答(2 个)

delta_t=0.001; % Sampling time
fs=1/delta_t; % Sampling frequency
t = 0:delta_t:pi;% Time space
N = 2048; % Block size
y1=2*sin(2*pi*1*t)+4*sin(2*pi*2*t)+3*sin(2*pi*4*t);
y2=2*cos(2*pi*1*t)+4*cos(2*pi*2*t)+3*cos(2*pi*4*t);
Y1 = abs(fft(y1, N));
Y2 = abs(fft(y2, N));
f=(0:length(Y1)-1)*fs/length(Y1);
plot(f, Y1, 'r-', f, Y2, 'b'), grid on, legend('Y1', 'Y2', 'location', 'SouthEast')
title 'FFT of y_1(t) and y_2(t)'
xlim([0, 10])
shg

类别

帮助中心File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

提问:

2011-2-21

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by