1. For Continuous Time Sequence:
Use the function: plot(X-axis, Y-axis)
For example to plot a parabolic function p(t)= At^2 for t>=0
0 for t<0
Code:
%UNIT PARABOLIC FUNCTION
t=linspace(-20,20,20); %range of X-asis
A=1; %amplitude of the function for A=1 it is called unit parabolic function
p=[t>=0].*(A.*t.^2)/2; %parabola equation as defined above
subplot(1,2,1); %the graph occupies 1st position in 1x2 grid
plot(t,p); %plot(X-axis is represented here as t, Y-axis is represented by p here)
xlabel('t---->') %naming the x-axis in the graph
ylabel('p(t)---->'); %naming the y-axis in the graph
title('Unit parabolic Signal'); %title of the graph
grid on;
The output graph is shown below:
2. For Discrete Time Sequence:
Use the function: stem(X-axis, Y-axis)
For example to plot a parabolic function p(t)= At^2 for t>=0
0 for t<0
Code:
%UNIT PARABOLIC FUNCTION
t=linspace(-20,20,20); %range of X-asis
A=1; %amplitude of the function for A=1 it is called unit parabolic function
p=[t>=0].*(A.*t.^2)/2; %parabola equation as defined above
subplot(1,2,1); %the graph occupies 2nd position in 1x2 grid
stem(t,p); %stem(X-axis is represented here as t, Y-axis is represented by p here)
xlabel('t---->') %naming the x-axis in the graph
ylabel('p(t)---->'); %naming the y-axis in the graph
title('Unit parabolic Signal'); %title of the graph
grid on;
The output graph is shown below:
So from the above two examples it is clear that we can generate the continuous time graph using plot function and discrete time graph using stem function for the same function keeping all other lines of code same.
Comments
Post a Comment