Hi, I have gone through your code. I think you are getting Array indexing error. Its due to these following reasons.
- In this statement
y = zeros(size(x));
y(0) = 1;
The code trying to access Zeroth element, but as we know Array indexing in MATLAB is always positive, i.e. It will start from ‘1’.
To set initial value of y you can do
2. Also, in the for loop you should start indexing from ‘1’ instead of ‘0’. i.e.