matlab coding - university of waterloo engineering computing

Post on 19-Dec-2021

7 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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  

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

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

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

•  t=-­‐2:.05:2  •  T=2;  •  x=  sin(2*pi*t/T)  •  plot(t,x)  

x(t)=sin(2*pi*t)  y(t)=cos(2*pi*t)  

•  In  the  same  plot  •  Use  ‘hold  on’  before  plot  

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

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  

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

•  Only  do  it  for  t>=0  

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

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

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

top related