Array indices must be positive integers or logical values.
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
gcoord
0 0
0 0
0 0
0 0
.........
Array indices must be positive integers or logical values.
this error is coming please help
0 commentaires
Réponses (1)
Steven Lord
le 8 Mai 2023
Usually this happens when you try to use 0 as an index. Indices in MATLAB start at 1 not 0.
x = 1:10;
This will work:
y(1:2:20) = x.^2
This won't. I've wrapped it in try and catch so code later in this answer can run.
try
z(0:2:19) = x.^2
catch ME
fprintf("This code threw error: %s\n", ME.message)
end
To fix this error, use indices that start at 1 not 0.
Alternately you could be trying to call a function but there's a variable by that name instead. In this case rename the variable so it doesn't have the same name as the function.
q = sin(pi)
sin = 42;
w = sin(pi)
If you need further help you will need to show us a small sample of code with which you can reproduce this error.
0 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!