Open In App

MATLAB Sine Wave Plot

Last Updated : 08 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

A sine wave or sinusoidal wave is a periodic function that involves the trigonometric sine function along with other factors such as Amplitude, frequency, and time instant of the wave. The general form of a sine wave function is:

Syntax:

f(t) = A*sin(w*t + theta)

Where,

  • A = amplitude
  • w = angular frequency of the wave, which is 2 *pi * frequency
  • t = time variable/ or any variable

Let’s see the plotting of this same function in MATLAB with different examples.

Example 1:

Matlab




% MATLAB code for sine wave plot
% Frequency
    freq = 0.2*pi; 
 
% Angular frequency
    w = 2*pi*freq; 
 
% Amplitude
    A = 1.25;  
 
% Values of variable argument
    t = linspace(0,pi,10000);  
 
% Sin wave function
    ft = A * sin(w*t);
 
% Sine wave plot
  plot(t, ft), title("Sine Wave"),
  xlabel("Time"), ylabel("Sine wave function")


Output:

 

Let us create a Sine wave function with phase angle pi/2.

Example 2:

Matlab




% MATLAB code for sine wave
% Frequency
  freq = 0.2*pi; 
   
% Angular frequency
  w = 2*pi*freq; 
   
% Amplitude
  A = 1.25; 
  t = linspace(0,pi,10000); 
   
% Values of variable argument
  theta = pi/2;
   
% Phase angle
% Sin wave function
  ft = A * sin(w*t + theta);
 
% Sine wave plot
  plot(t, ft), title("Sine Wave with phase pi/2"),
  xlabel("Time"), ylabel("Sine wave function")


Output:

 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads