Subscript indices must either be real positive integers or logicals.
The code that I was using was taken from a Stack Overflow Post and the relevant line of code that generated the error is as follows:
% Process the signal with the matched filter
y = filter(b,1,x);
This was resulting in the above error. The issue was that in some previous code, I had defined the variable 'filter' as the coefficients of a filter, and this was still in my workspace. Thus MATLAB was interpreting 'filter' as a variable instead of a function, and so the parameters passed to the function were actually interpreted as indicies within the variable, which must be whole numbers. So to fix the error, before calling the line with the 'filter()' function, I just have to delete the variable with the same name. This can be done using the 'clear' command. There is the possiblity to clear the entire workspace of variables, or rather just the specific offending variable.
To clear the variable that is causing the problem, I used the following command:
clear('filter')
where filter is my variable name. Alternatively just the command 'clear' on its own will clear all variables from the workspace:
clear
No comments:
Post a Comment