As others have pointed out, this error message typically occurs when you're indexing an array with incompatible values (usually decimals, negatives or non-numeric types).
There seems to be a lot of indexing in the code attached; could you post the full error message, including the line where the error has occured?
At first glace, I'm not sure that 'fun' got assigned properly, there could be a bug. You may check that 'fun' works as expected before invoking 'fun(j)' later.
1 Comment
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/641135-array-not-positive-real-value#comment_1119100
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/641135-array-not-positive-real-value#comment_1119100
Sign in to comment.