I know that my equations are correct, but the error is telling me i need to use logical or positive values
1 view (last 30 days)
Hello, My current code is given below along with my error message. I know that my equations are correct so i do not know how to get the error message to go away
Array indices must be positive integers or logical values.
Error in Project5 (line 6)
% Let U(x,t)-U(x,0) = ZN
Alan Stevens on 30 Jun 2020
You are trying to index Z1 with 0.01. i.e you are telling MATLAB to to create Z1(0.01). However, the argument to Z1 (and the others) must be an integer.
Try something like
i = 1:10000
t = i/10
Z1(i) = ... etc.
More Answers (1)
Gurpreet Singh on 30 Jun 2020
This error occurs when you attempt to index into an array using indices that are not positive integers or logical values.
Here you are using double value array "t" for indexing array Z1, Z2, Z3, and Z4. However, any matrix or array argument should always be a positive integer or logical value.
Please refer to the https://in.mathworks.com/help/matlab/learn_matlab/array-indexing.html (array-indexing) documentation for more information on how to do indexing in arrays.