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 commentaires

Paulo Silva
Paulo Silva le 21 Fév 2011
doc fft
zaini
zaini le 21 Fév 2011
please use code writing mode, to make it more readable
khalid
khalid le 21 Fév 2011
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?

Connectez-vous pour commenter.

Réponses (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 16 Mai 2019

0 votes

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

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by