Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Matlab newbie, I need help with fft of sin/cos functions

Status
Not open for further replies.

Dexter2011

Newbie level 2
Joined
Mar 2, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,304
Hi all!

I am a complete Matlab newbie. I have an assignment to complete in Matlab, and I am having some, what I am sure, are elementary difficulties. My assignment is using the Fourier Transform function. Here are the instructions:

1. Generate the following functions:
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)

2. 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 delta t at least 3 times smaller than this value and calculate y1(t) and y2(t).

3. Calculate Fourier Transform (fft) of y1 and y2 and plot your results using frequency as the x axis and amplitude as the y axis. Plot the phase also.
Given:
f=[0:1/length(y1):1/2]*(1/delta t)
plot(f,abs(y1(1:length(f)))'-*')

...Ok, as for #1 and 2, I think I know how to get the delta t. I am not sure how to define time. I have searched the web and found several similar but differing functions: t=(0:n-1)*(1/fs); t=(0:1/fs:n); etc. Where do I get the n? Which equation do I use?

And for #3, I am not sure how to define frequency. Again, I have found several functions differing slightly. For example in the given frequency equation, what is the length(y1)? Why is frequency defined from 0 to 1/2...where does the 1/2 come from? And where do I get the length(f)?

I'm sure these are basic questions, but I am in a grad class where I believe we are expected to already know Matlab and this is literally my first go at it. I would really appreciate any help you could give.

Thank you!!
 

Hi Dexter
I think you should have been taught a course on Digital Signal Processing in which you are told how to sample a continuous time signal. As you know that if x(t) is a continuous time signal and x[n] is its discrete time representation then x[n]=x(nT) where 'T' is the sampling time which you have written 'delta t'. So, time t is t=nT where 'n' is the discrete time index say having values 0,1,2,...,N-1. So, t=(0:N-1)*T where T=1/fs.

Now you also know the relationship between the frequencies of Fourier transform of x(t) and x[n]. In fact if F is the frequency of continuous time signal and f is that of discrete time then
f=FT
for -0.5<=f<0.5
So,
F=(0:length(y1)-1)/(length(y1)*2)*1/(delta t).
where length() is MATLAB's function returning the length of a variable like if A=[1 -1 6 5]; then length(A) will be 4.
 
Hi MHanif,

Though I am in a graduate engineering program, my undergrad is in Math, and I have never taken an engineering course before. So unfortunately, this is all very new to me, and I've had to just dive in head first. Your explanation helped me a lot, and I understand this aspect of Matlab now. So thank you so much!!!

Dexter
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top