matlab coding - university of waterloo engineering computing
TRANSCRIPT
![Page 1: MATLAB Coding - University of Waterloo Engineering Computing](https://reader030.vdocument.in/reader030/viewer/2022012809/61be69fc29421e13b6217c4a/html5/thumbnails/1.jpg)
Remote access to Matlab • Start→All Programs→Accessories→Remote Desktop Connec9on • engterm.uwaterloo.ca • Win Key +’R’-‐> ‘matlab’
• For Apple (troubleshoo9ng): – Use soKware CoRD – Downgrade remote desktop client to version 1.0
• Otherwise download/install – SCILAB – OCTAVE
![Page 2: MATLAB Coding - University of Waterloo Engineering Computing](https://reader030.vdocument.in/reader030/viewer/2022012809/61be69fc29421e13b6217c4a/html5/thumbnails/2.jpg)
x(t)=sin(2*i*t)
• Time from -‐2s to 2s • (Period here is 1)
![Page 3: MATLAB Coding - University of Waterloo Engineering Computing](https://reader030.vdocument.in/reader030/viewer/2022012809/61be69fc29421e13b6217c4a/html5/thumbnails/3.jpg)
x(t)=sin(2*pi*t)
• t=-‐2:.05:2 • T=2; • x= sin(2*pi*t/T) • plot(t,x)
![Page 4: MATLAB Coding - University of Waterloo Engineering Computing](https://reader030.vdocument.in/reader030/viewer/2022012809/61be69fc29421e13b6217c4a/html5/thumbnails/4.jpg)
x(t)=sin(2*pi*t) y(t)=cos(2*pi*t)
• In the same plot • Use ‘hold on’ before plot
![Page 5: MATLAB Coding - University of Waterloo Engineering Computing](https://reader030.vdocument.in/reader030/viewer/2022012809/61be69fc29421e13b6217c4a/html5/thumbnails/5.jpg)
x(t)=sin(2*pi*t) y(t)=cos(2*pi*t)
• t=-‐2:.05:2 • T=2; • x= sin(2*pi*t/T) • y=cos(2*pi*t/T) • hold on • plot(t,x,'red') • plot(t,y,'blue') • legend('x=sin(2*pi*t)',
'y=cos(2*pi*t/T)'); • hold off • xlabel('9me') • ylabel('signal') • 9tle('Tutorial 1:1(a)');
![Page 6: MATLAB Coding - University of Waterloo Engineering Computing](https://reader030.vdocument.in/reader030/viewer/2022012809/61be69fc29421e13b6217c4a/html5/thumbnails/6.jpg)
x(t)=sin(2*pi*t) y(t)=cos(2*pi*t)
• Using subplot • subplot(2,1,1) and subplot(2,1,2) before plobng
![Page 7: MATLAB Coding - University of Waterloo Engineering Computing](https://reader030.vdocument.in/reader030/viewer/2022012809/61be69fc29421e13b6217c4a/html5/thumbnails/7.jpg)
x(t)=sin(2*pi*t) y(t)=cos(2*pi*t)
• t=-‐2:.05:2 • T=2; • x= sin(2*pi*t/T) • y=cos(2*pi*t/T) • subplot(2,1,1) • plot(t,x,'red') • xlabel('(me') • ylabel('x=sin(2*pi*t)') • • subplot(2,1,2) • plot(t,y,'blue') • xlabel('(me') • ylabel('y=cos(2*pi*t)') • • 9tle('Subplot');
![Page 8: MATLAB Coding - University of Waterloo Engineering Computing](https://reader030.vdocument.in/reader030/viewer/2022012809/61be69fc29421e13b6217c4a/html5/thumbnails/8.jpg)
• Only do it for t>=0
![Page 9: MATLAB Coding - University of Waterloo Engineering Computing](https://reader030.vdocument.in/reader030/viewer/2022012809/61be69fc29421e13b6217c4a/html5/thumbnails/9.jpg)
• clc; %clear command window • clear all; %clear memory • t=0:.05:2; • • x= 3*exp(-‐2*t); • • plot(t,x); • xlabel('9me') • ylabel('signal') • 9tle('tutorial 1:1(b)')
![Page 10: MATLAB Coding - University of Waterloo Engineering Computing](https://reader030.vdocument.in/reader030/viewer/2022012809/61be69fc29421e13b6217c4a/html5/thumbnails/10.jpg)
• Do it for -‐2>t>2
![Page 11: MATLAB Coding - University of Waterloo Engineering Computing](https://reader030.vdocument.in/reader030/viewer/2022012809/61be69fc29421e13b6217c4a/html5/thumbnails/11.jpg)
clc; %clear command window clear all; %clear memory t=-‐2:.05:2; for i=1:length(t) if (t(i)<0) x(i)= 0; else x(i)= 3*exp(-‐2*t(i)); end end plot(t,x); xlabel('9me') ylabel('signal') 9tle('tutorial 1:1(b)')