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

조회 수: 41 (최근 30일)
tomer polsky
tomer polsky 2018년 6월 21일
편집: tomer polsky 2018년 6월 21일
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
Adam
Adam 2018년 6월 21일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

tomer polsky
tomer polsky 2018년 6월 21일
편집: tomer polsky 2018년 6월 21일
if could enter this link ,this is the book I am using and you could see what I am talking about (page 45)

카테고리

Help CenterFile Exchange에서 Signal Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by