Advertisement
vinay586

Function for Signal Addition

Oct 16th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.36 KB | None | 0 0
  1. a = [1 2 3]
  2. ax = -2:0
  3. b = [4 5 6]
  4. bx = 0:2
  5. [z,v] = addition(a, ax, b ,bx)
  6.  
  7.  
  8. function [add,n3] = addition(x, n1, y, n2)
  9.  
  10. n3 =min (min(n1) ,min( n2 ) ) : max ( max ( n1 ) , max ( n2 ) );
  11. s1 =zeros(1,length (n3) );
  12. s2 =s1;
  13. s1 (find ( ( n3>=min( n1 ) ) & ( n3 <=max ( n1 ) )==1 ) )=x;
  14. s2 (find ( ( n3>=min ( n2 ) ) & ( n3 <=max ( n2 ))==1) )=y;
  15. add=s1 +s2;
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement