Advertisement
Md_hosen_zisad

matlab ex4

Oct 10th, 2018
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. %rectangular signal
  2. Amp1=400;
  3. Amp2=320;
  4. freq=300;
  5. cycle=3;
  6. subplot(2,1,1);
  7. x1=0: 0.00001: 0.01;
  8. y1=Amp1*square(2*pi*freq*x1+0)
  9. x2=0: 0.00001:0.01;
  10. y2=Amp2*square(2*pi*freq*x1+0)
  11. plot(x1,y1,x2,y2)
  12.  
  13. title('Rectangular Signal')
  14. set(gca,'xtick',0:0.00166666:0.01);
  15. set(gca,'xticklabel',{'0','pi','2pi','3pi','4pi','5pi','6pi'})
  16. set(gca,'ytick',-400:80:400);
  17. set(gca,'yticklabel',{'-400','-320','-240','-160','-80','0','80','160','240','320','400'});
  18.  
  19. xlabel('time');
  20. ylabel('amplitude');
  21.  
  22. %triangular
  23.  
  24. Amp1=280;
  25. Amp2=340;
  26. freq=450;
  27. cycle=8;
  28. subplot(2,1,2);
  29. x1=0: 0.00001: 0.01777777;
  30. y1=Amp1*sawtooth(2*pi*freq*x1)
  31. x2=0: 0.00001:0.0177777;
  32. y2=Amp2*sawtooth(2*pi*freq*x1)
  33. plot(x1,y1,x2,y2)
  34.  
  35. title('Rectangular Signal')
  36. set(gca,'xtick',0:0.004425:0.017777);
  37. set(gca,'xticklabel',{'0','4pi','8pi','12pi','16pi'})
  38. set(gca,'ytick',-350:70:350);
  39. set(gca,'yticklabel',{'-350','-280','-210','-140','-70','0','70','140','210','280','350'});
  40.  
  41. xlabel('time');
  42. ylabel('amplitude');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement