By
Prashanthan Uthayakumar (w1412291)
1.
(a) Create your own plots of the unit step, and triangular signals. Now, use the same approach to create the plots of the rectangular signal ( ) and the signal ( ) shown in the Figure below. Include in your report the texts of the programmes you have used and copies of the obtained plots.
(b) Use MATLAB help to learn about xlabel, and ylabel commands. When creating the plots in part (a) and throughout the report make sure that the axes of the plots are always properly labelled.
(c) Use different line styles, e.g. thicknesses, shapes (broken continuous etc.), and colours in the created plots. MATLAB help on the plot function (>>help plot) instructs how to achieve these effects.
[30 marks]
a)
Plot of a unit step(t)
clear all time=-3:0.01:5; ind1=find(time=0); x(ind1)=0; x(ind2)=1; plot(time,x,'linewidth',2) set(gca,'fontsize',12) axis([-3, 8, -2, 4]) grid on xlabel('x'); ylabel('y'); title('Unit Step')
Plot of a triangular signal
clear all time=-8:0.001:10; ind1=find(time=-2 & time < 0); ind3=find(time>=0 & time < 2); ind4=find(time>=2); y(ind1)=0.5; y(ind2)=1+time(ind2); y(ind3)=1-time(ind3); y(ind4)=0.5; plot(time,y) plot(time,y,'linewidth',3) set(gca,'fontsize',12) axis([-3, 3, -1, 2]) grid on xlabel('x'); ylabel('y'); title('Triangular Signal') This part of the task also required me to add labels to both the x and y axis using the xlabel and ylabel command. In order for me to reach that, I had to use: xlabel(‘text’) and ylabel(‘text’) where text is a string variable.
Approach to create the given signal x(t).
First step was to create a Rect(t). clear all time=-3:0.001:4; ind1=find(time=-0.5 & time < 0.5); ind3=find(time>0.5); y(ind1)=0; y(ind2)=1; y(ind3)=0; plot(time,y) plot(time,y,'linewidth',3) set(gca,'fontsize',12) axis([-3, 3, -1, 2]) grid on xlabel('x'); ylabel('y');
title('Rect(t)')