MATLAB Sine Wave Plot
Last Updated :
08 Nov, 2022
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
freq = 0.2*pi;
w = 2*pi*freq;
A = 1.25;
t = linspace(0,pi,10000);
ft = A * sin(w*t);
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
freq = 0.2*pi;
w = 2*pi*freq;
A = 1.25;
t = linspace(0,pi,10000);
theta = pi/2;
ft = A * sin(w*t + theta);
plot(t, ft), title( "Sine Wave with phase pi/2" ),
xlabel( "Time" ), ylabel( "Sine wave function" )
|
Output:
Share your thoughts in the comments
Please Login to comment...