Error: Conversion to logical from sym is not possible.

조회 수: 3 (최근 30일)
geometry geometry
geometry geometry 2018년 3월 19일
댓글: Walter Roberson 2018년 3월 19일
Why I get the error in title?
syms x h myconv
myconv=0;
h=0;
x(n)=(1/2^(-n+1))*(heaviside(n+2)-heaviside(n-2));
if (0<n)&&(n<7)
for i=-1000:1:n
h=h+(sin(2*i)+(-1)^i)*(heaviside(i+3)-heaviside(i-5));
end
else
h=0;
end
for i=-1000:1:1000
myconv=x(i)*h(n-i)+myconv;
end
N=-5:1:5;
figure
subplot(2,2,1);
stem(N, subs(x,n,N), 'bo');
title('x(n)')
subplot(2,2,2);
stem(N, subs(h,n,N), 'ro');
title('h(n)')
subplot(2,2,3);
stem(N, subs(myconv,n,N), 'ko');
title('convolution')
  댓글 수: 5
Walter Roberson
Walter Roberson 2018년 3월 19일
You do not change your code to fix this. Your entire premise is broken. You are not going to be able to find the infinite limit of the convolution of arbitrary functions using the techniques you are using. You would need to apply analytical reasoning to figure out the zone in which the function is not zero, do the calculation within that zone, and then the infinite limit is the same since going out further will just be zeros outside that range.
Walter Roberson
Walter Roberson 2018년 3월 19일
"Error using : (line 38) Cannot compute the number of steps from -1000 to n by 1."
It is not permitted to have a symbolic variable as a bound for a for loop.

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

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by