Hello,
I see that you're working on implementing an N-point moving average filter in MATLAB and are encountering a couple of issues. Let's address these errors step by step:
The error 'Unrecognized function or variable x' is due to x not being defined before it's used in the loop. In MATLAB, you need to define all the variables before you can use them. Ensure that x is an existing array with your input signal data before the loop starts.
Regarding the error stating 'Array indices must be positive integers or logical values', note that MATLAB indexing begins at 1. When assigning values to y(k), it is crucial to ensure that the indices used to access elements of x fall within the permissible range. This means indices should be greater than or equal to 1 and less than or equal to the length of the array x. Any attempt to access x using an index outside this range will result in an error.
For more information on arrays, refer the below documentation page:
Hope this helps.