Open In App

MATLAB Sine Wave Plot

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,



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

Example 1:




% 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 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:

 


Article Tags :