I am having this error "Index in position 2 is invalid. Array indices must be positive integers or logical values." in my file. Can you please help me in resolving this.
99 views (last 30 days)
Show older comments
I am very new to matlab and am having some syntax errors. The code is due for submission in a few days. I will be very grateful for solution. . . .
0 Comments
Answers (2)
MUHAMMED IRFAN
on 10 Dec 2018
In MATLAB, array indexing starts at 1(not zero).
Inside the function Duffusion() you have a number of for loops in each if-else cases.
for i = 1:(length(x)-1) % Iterate over tri diagonal
L(i,i) = 2/(delta^2)+SigmaA/D; % Diagonal Terms
L(i,i+1) = -1/(delta^2); % Above diagonal term
L(i,i-1) = -1/(delta^2); % Below diagonal term
end
In each of these for loops, you iterate the value of i from 1 to something. But when i=1, you have L(i,i-1) as L(1,0) which is invalid in MATLAB. And thus the error.
0 Comments
Andualem
on 25 Feb 2023
how to fix this problem in mimo landas(:,j) = diag(V);
1 Comment
Image Analyst
on 25 Feb 2023
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1306765/image.png)
You should probably start your own question after you read this:
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!