MATLAB Implementation of Karplus Strong algorithm with filter function? I want to implement following function: y = ksalgrithm(x, alpha, M, Nout) where 


x is the input vector with length Nout
alpha=0.99
Nout is the length of the output vector. 


The algorithm should do the convolution of $y[n]=(h_1\star x)[n]$, where $h_1[n]$ is the inverse of the $z$-transformation of $H_1(z)$. The input signal should have values $l = T_0 \cdot f$ and filled up with zeros until the vector has the length of Nout.

I want to use MATLAB's filter.

Nout = length(x);
M = T_0*fs;
alpha = 0.99;
function [ y ] = ksalgorithm( x, alpha, M, Nout )
    syms z;
    H = filter(1,1-alpha*z^(-M),x);
    H_1 = 1/(1-alpha*z^(-M));
    h_1 =  iztrans(H_1);

    y = zeros(x);
    ...


I get always this error? 

Undefined function 'filter' for input arguments of type 'sym'.
Error in ksalgorithm (line 23)
    H = filter(1,1-alpha*z^(-M),x);
The filter(b,a,x) function of MATLAB does not operate on symbolic variables. Your line of code 

syms z


creates a symbolic variable z, in MATLAB environment, and later
you feed this variable into the filter() function through its second argument in this line:

H = filter(1,1-alpha*z^(-M),x);


where the filter(b,a,x) function, in this mode is expecting a numerical coefficient vector $a[k]$ associated with the DT system that's defined by the coefficient vectors $a[k]$ and $b[k]$.

In order to get the filter() function working, replace the symbolic expression 

1-alpha*z^(-M) 


with the numerical one, given integer M and real alpha

a = [1 zeros(1,M-1) -alpha]