Dexter2011
Newbie level 2
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!!
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!!