Signal addition {x1(n)}+{x​2(n)}={x1(​n)+x2(n)}

41 views (last 30 days)
tomer polsky
tomer polsky on 21 Jun 2018
Edited: tomer polsky on 21 Jun 2018
hello I am currently studying DSP in matlab from a book . and in the book the is signal addition {x1(n)}+{x2(n)}={x1(n)+x2(n)}
while x1(n)!=x2(n) how ever for some reason my function does not work :
x1=1:1:5
x2=1:0.2:2.2
n1=length(x1)
n2=length(x2)
[y,n]=sigadd(x1,n1,x2,n2)
the function itself :
function [y,n]=sigadd(x1,n1,x2,n2)
max_n=max(max(n1),max(n2))
min_n=min(min(n1),min(n2))
n=(min_n:max_n)
y1=zeros(1,length(n))
y2=y1
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2
y=y1+y2
end
  1 Comment
Adam
Adam on 21 Jun 2018
What are you expecting to be the result of this addition? Your sigadd code only takes into consideration a small section of signal length representing the difference in signal lengths ( +1 ) and your find instructions are hard to understand.
But again, it is hard to see what the expected result is of adding these two signals. If x1 and x2 are meaningful then do you really want to be adding together signal values with different x values?
Those x1 and x2 values suggest you have two bits of signal of differing sample rate, one of which only goes as far as 2.2 while the other ranges up to 5.

Sign in to comment.

Answers (1)

tomer polsky
tomer polsky on 21 Jun 2018
Edited: tomer polsky on 21 Jun 2018
if could enter this link ,this is the book I am using and you could see what I am talking about (page 45)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!