Error: Conversion to logical from sym is not possible.
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 19 Mär. 2018
n is not defined.
Based on your previous questions, n would be expected to be symbolic, but your code here is treating it as numeric and as a positive integer, up until you try to subs() using n as the name of a variable to substitute for.
geometry geometry
am 19 Mär. 2018
geometry geometry
am 19 Mär. 2018
Walter Roberson
am 19 Mär. 2018
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
am 19 Mär. 2018
"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.
Antworten (0)
Kategorien
Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!