Advertisement
Sourav_CSE

SS Lab Class No 7

Nov 6th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. %{
  2. SS Lab Class 7
  3. Rahat Sir
  4. Date: 06-11-2019
  5. %}
  6. % Solution of Differential Equation
  7. %f = 'Dy + y - cos(t)';
  8. %y = dsolve(f,'y(0)=2');
  9. %ezplot(y,[1 20])
  10. %f ='2*D2y+Dy+y-D(cos(t))';
  11. % Evaluate difference Equation
  12. b = [.067 .1349 .675];
  13. a =[1 -1.143 .4128];
  14. n = 1:20;
  15. x = (.5).^n;
  16. zi = filtic(b,a,[1 2]);
  17.  
  18. y = filter(b,a,x,zi);
  19. stem
  20. %% Fourier Series
  21. T0 = 1; E =1; w0 = 2*pi; a0 =E/2;
  22.  
  23. n = 20;
  24. f = a0/2;
  25. t = -1.5:.01:1.5;
  26.  
  27. for N=1:n
  28. an = ((2*E)/(N*w0*T0))*(sin(N*pi/2)-sin(3*N*pi/2));
  29. f = f+ an .* cos(N*w0*t);
  30. end
  31.  
  32. plot(t,f)
  33.  
  34. %f = a0/2 + sum(an*cos nwt)
  35. %% another fourier Series
  36. T0 = 2*pi; w0=1; a0=1/2; E = 1;
  37. n =20;
  38. f = a0/2;
  39. t = -1.5:.01:1.5;
  40.  
  41. for N=1:n
  42. bn = -1/(n.*pi);
  43. f = f+ bn.*cos(N*wo*t);
  44. end
  45. plot(t,f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement