Vulpes

EE354HW01

Sep 4th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.08 KB | None | 0 0
  1. function HW1(problem_no)
  2.  
  3.     switch(problem_no)
  4.         case(1)
  5.  
  6.             % 1.
  7.             T = 2;
  8.             f = 1/T;
  9.             w0 = 2*pi*f; % w0 better equal pi
  10.             Amp = 1.5;
  11.             t = linspace(0,3*T,1+2^7)';
  12.             % x = Amp*(2/pi)*asin(sin(w0*t));
  13.             x = Amp*(2*(floor(t)/2==floor(floor(t)/2))-1);
  14.             plot(t,x);
  15.  
  16.             A = [];
  17.             % A0 = integral(x(t)*e^0),t,0,T);
  18.             % A0 = int(x(t),t,0,T)
  19.             % A0 = 0
  20.             % A1 = int(x(t)*e^(-j*k*w0*t),t,0,T);
  21.             % A1 = int(x(t)*e^(-j*w0*t),t,0,T)
  22.             % A1 = int1 + int2
  23.             % int1 = int(1.5*e^(-j*w0*t),t,0,1)
  24.             % int2 = int(-1.5*e^(-j*w0*t),t,1,2)
  25.             % int1 = 1.5*(e^(-j*w0*1)-e^0)
  26.             % int1 = 1.5*(-1 - 1) = -3
  27.             % int2 = -1.5*(e^(-j*w0*2)-e^(-j*w0*1))
  28.             % int2 = -1.5*(1 - -1) = -3
  29.             % A1 = -3 + -3
  30.             % A1 = -6
  31.             % An1 =
  32.     case(2)
  33.     case(3)
  34.  
  35.  
  36.     % 3.
  37.  
  38.     % H(j*w) = (w<=50);
  39.  
  40.     T = pi/6;
  41.     f = 1/T;
  42.     w0 = 2*pi*f;
  43.  
  44.     % what are values kf = [k ; k+1] where A(kf(1)) = 1 & A(kf(2)) = 0
  45.     % (lowpass)
  46.  
  47.     kf = [0;0];
  48.     kf(2) = 0;
  49.     kf(1) = w0;
  50.     k = 0;
  51.     while (kf(2) <= 50)
  52.     k = k+1;
  53.     kf(1) = kf(2);
  54.     kf(2) = w0*k;
  55.     end;
  56.  
  57.     otherwise
  58.     disp('no problem selected');
  59.     end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment