Advertisement
MagnusArias

PTS | Zad2 - dykretny

Nov 16th, 2017
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.95 KB | None | 0 0
  1. function [ y ] = splot_dyskretny( base, x2, p1, p2 )
  2. % Objaśnienia
  3. MaxLen = length(base) + length(x2);   % dlugość sygnałów
  4. MinLen = MaxLen-1;                  % długość wektora wynikowego
  5. mv = p1+p2;                         % przesunięcie
  6.  
  7. dt=mv:MinLen-1+mv;
  8. xx1 = zeros(1, MinLen-length(base));
  9. base = [base xx1];
  10.  
  11. xx2 = zeros(1, MinLen-length(x2));
  12. x2 = [x2 xx2];
  13.  
  14. y=zeros(1,MinLen);                  % wektor wynikowy
  15.  
  16. for n=1:MinLen
  17.     for k=1:n
  18.         y(n) = y(n)+base(k)*x2(n-k+1); % obliczanie wartosci splotu
  19.     end
  20. end
  21. % Wykresy
  22. subplot(4,1,1); stem(dt-mv+p1,base);grid on; title('Sygnał pierwszy')
  23. subplot(4,1,2); stem(dt-mv+p2,x2);grid on; title('Sygnal drugi')
  24. subplot(4,1,3:4); stem(dt,y);grid on; title('splot')
  25. end
  26.  
  27.  
  28.  
  29. base = [9 4 3 3]    % numer indeksu, od 0
  30. x1 = [1 1 0 0]      % od 0
  31. x2 = [1 2 1 -1 -1]  % od -2
  32. x3 = [2 0 0 -1 -1]  % od +2
  33.  
  34. splot_dyskretny(base, x1, 0, 0)
  35.  
  36.  
  37.  
  38. w sprawku te trzy funkcje + sploty
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement