why I get error using stem?

I tried this code to stem the convolution of two discrete time signals x and h without using conv function.
but I get error entering x and h which are commented in the code. how can I fix it?
syms x h myconv n
myconv=0;
% x(n)=(n==0|n==4)-2*heaviside(n+3)+2*heaviside(n-3);
% y(n) = (n==0|n==4)-2*heaviside(n+3)+2*heaviside(n-3)-(-2*heaviside(2*n+5)+2*heaviside(2*n-1));
H(n)=heaviside(n)+(1/2)*piecewise(n==0,1,0);
x=input('Enter x: ');
h=input('Enter h: ') ;
h = symfun(eval(h), n);
x = symfun(eval(x), n);
h = matlabFunction(h);
x = matlabFunction(x);
for i=-1000:1:1000
myconv=x(i)*h(n-i)+myconv;
end
stem(N, subs(myconv,n,N), 'ko');

4 commentaires

M
M le 19 Mar 2018
You have an error using the eval function ?
If yes, why are you using it ?
If not, post the entire error message that you get.
geometry geometry
geometry geometry le 19 Mar 2018
Modifié(e) : geometry geometry le 19 Mar 2018
thanks it worked fine!
Walter Roberson
Walter Roberson le 19 Mar 2018
N is not defined.
geometry geometry
geometry geometry le 19 Mar 2018
But there is a problem in my plotting. the logic input (n==0|n==4) doesn't affect the plot. do you know how can I fix this?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by