Advertisement
Ostu

Untitled

May 5th, 2021
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.77 KB | None | 0 0
  1. h=[-1, 3, 4, 2]
  2. x=[1, 3, -1, 2, 5]
  3.  
  4. odx = flip(x)
  5.  
  6. c1=numel(h)
  7. c2=numel(odx)
  8.  
  9. m=c2;
  10. n=2;
  11. p=c1-c2+2;
  12. u=(c1+c2)-1;
  13. WE=zeros(1,(c1+c2)-1);
  14. WY=zeros(1,(c1+c2)-1);
  15. for i=1:u
  16.     if i <= c1
  17.         for z = 1:i
  18.             WE(z) = [h(1,z)*odx(1,m)];
  19.             m=m+1;
  20.         end
  21.         m=c2-i;
  22.         WY(i)=sum(WE);
  23.         WE=zeros(1,c2);
  24.     end
  25.     if i > c2 && i <=c1
  26.         H=n;
  27.         for z=1:c2
  28.             WE(z)=[h(1,H)*odx(1,z)];
  29.             H=H+1;
  30.         end
  31.         n=n+1;
  32.         WY(i)=sum(WE);
  33.         WE=zeros(1,c2);
  34.     end
  35.     if i > c1
  36.         H=p;
  37.         for z=1:c2-1
  38.             WE(z)=[h(1,H)*odx(1,z)];
  39.             H=H+1;
  40.         end
  41.         p=p+1;
  42.         c2=c2-1;
  43.         WY(i)=sum(WE)
  44.         WE=zeros(1,c2);
  45.     end
  46. end
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement