Advertisement
rootuss

sinus

Oct 14th, 2019
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.49 KB | None | 0 0
  1. function[n,x]=sinus(A,f,fs,T,faza)
  2. x=zeros(1,fs*T);
  3. n=x;
  4. k=1;
  5. for i=0 : 1/fs : T
  6.     n(k)=i;
  7.     x(k)=A*sin(2*pi*f*i+faza*pi/180);
  8.     k=k+1;
  9. end
  10.  
  11. >> [t,y]=sinus(10,2,200,2,0);
  12. >> plot(t,y);
  13.  
  14. >> [t,y]=sinus(10,2,200,2,0);
  15. plot(t,y);      % po plocie usuwane są np podpisy osi x i y więc najpierw plot a potem można dodać opisy osi(gdy po dodaniu opisów naciśniemy plot to usuną się one
  16. >> xlabel('czas[s]');
  17. >> ylabel('amplituda');
  18. >> title('sinusoida');
  19. >> grid on
  20. >> [t,y]=sinus(10,2,200,2,90); %na cos
  21. >> [t,y]=sinus(10,2,200,2,190);
  22. >> plot(t,y);
  23. >> [t,y]=sinus(10,2,200,2,90);
  24. >> plot(t,y);
  25. >> help plot %podpowiedzi do czegoś
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement