Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [y,n] = sigadd(x1,n1,x2,n2)
- % implements y[n] = x1[n] + x2[n]
- % y = sum sequence over n, which includes n1 and n2
- % x1 = first sequence over n1
- % x2 = second sequence over n2 (n2 can be different from n1)
- a = [1 2 3]
- ax = -2:0
- b = [4 5 6]
- bx = 0:2
- [z,v] = addition(a, ax, b ,bx)
- function [add,n3] = addition(x, n1, y, n2)
- n3 =min (min(n1) ,min( n2 ) ) : max ( max ( n1 ) , max ( n2 ) );
- s1 =zeros(1,length (n3) );
- s2 =s1;
- s1 (find ( ( n3>=min( n1 ) ) & ( n3 <=max ( n1 ) )==1 ) )=x;
- s2 (find ( ( n3>=min ( n2 ) ) & ( n3 <=max ( n2 ))==1) )=y;
- add=s1 +s2;
- end
Add Comment
Please, Sign In to add comment