Learn Matlab: Sine Wave Analysis

  • Context: MATLAB 
  • Thread starter Thread starter zxc01
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The discussion focuses on using Matlab for sine wave analysis, specifically creating a sine wave, calculating its Fast Fourier Transform (FFT), and understanding the effects of phase shifts on both time-domain and frequency-domain representations. The user shared a demo program that successfully plots a sine wave and its Fourier transform, demonstrating the relationship between the discrete and continuous Fourier transforms. The program utilizes Matlab functions such as fft and fftshift to achieve these results, and the user recommends a specific lecture on Fourier transforms for deeper understanding.

PREREQUISITES
  • Basic knowledge of Matlab programming
  • Understanding of sine wave generation
  • Familiarity with Fast Fourier Transform (FFT) concepts
  • Knowledge of phase shifts in waveforms
NEXT STEPS
  • Learn how to manipulate sine wave parameters in Matlab
  • Explore Matlab's fft and fftshift functions in detail
  • Study the relationship between discrete and continuous Fourier transforms
  • Investigate the effects of phase shifts on FFT outputs
USEFUL FOR

Students and professionals in engineering, signal processing, and data analysis who are learning to use Matlab for waveform analysis and Fourier transform applications.

zxc01
Messages
2
Reaction score
0
Hello.

I have recently transferred courses, and am expected to know how to use Matlab, but have never been taught before. Therefore I have been trying to go through and teach myself some of the bits I will need to know from it.

We were told we had to know how to do certain things already and I have been going through these.


Create a sine wave, calculate the FFT of the sine wave, extract the frequency of the FFT of the sine wave from the FFT data, and know what happens to the time-domain and FFT-domain of this data if the phase of the sine wave were shifted by a few degrees.


I tried with the help of the getting started guide in Matlab itself and input:-

x=0:pi/100:2*pi
y=sin(x)
plot(x,y)

y=fft(x)

And couldn't do any of the others.

Would appreciate some help.
Thank you.
 
Physics news on Phys.org
I always get slighty confused about this so I wrote myself a demo program that does just this thing. It plots a sign wave and it's Fourier transform, showing spikes at just the right places.

Code:
clear all
% play with different values of fo
fo = 4;
N = 100; 
T = 2*pi;
t = linspace(0,T,N);

% the function and its fft (shifted so zero frequency occurs in the middle)
f = sin(2*pi*fo*t);
ft = fftshift(fft(f));

% frequency goes in steps 1/T
s = (-N/2+1:N/2) * 1/T;
figure(1),plot(t,f),title('f(t) versus t')
figure(2),plot(s,abs(ft)),title('fourier transform of f at s versus s')

As far as really understanding the relationship between the discrete Fourier transform and the continuous one, this lecture really cleared things up. It's lecture number 20 in an entire class on Fourier transforms. This is the class where he introduces the discrete Fourier transform. The whole class is amazing and I highly recommend it to everyone.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 16 ·
Replies
16
Views
15K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K