matlab coding - university of waterloo engineering computing

11
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

Upload: others

Post on 19-Dec-2021

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MATLAB Coding - University of Waterloo Engineering Computing

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

x(t)=sin(2*i*t)  

•  Time  from  -­‐2s  to  2s  •  (Period  here  is  1)  

Page 3: MATLAB Coding - University of Waterloo Engineering Computing

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

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

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

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

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

•  Only  do  it  for  t>=0  

Page 9: MATLAB Coding - University of Waterloo Engineering Computing

•  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

•  Do  it  for  -­‐2>t>2  

Page 11: MATLAB Coding - University of Waterloo Engineering Computing

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)')