Array indices must be positive integers or logical values.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
A = [1 2 3; -4 1 2; 0 9 -8];
B = [12; 13; -1];
solution = A\B
det = det(A)
Can anyone tell me why i keep getting error?
Array indices must be positive integers or logical values.
det = det(A)
0 commentaires
Réponses (3)
Torsten
le 17 Mai 2023
Modifié(e) : Torsten
le 17 Mai 2023
I don't get this error message (see above). But you should rename the result from det(A) - otherwise you have "overwritten" the built-in MATLAB function "det" with the numerical value -198.
2 commentaires
Steven Lord
le 17 Mai 2023
You will not be able to call the det function while a variable named det is in your workspace. Renaming the variable in your code will not rename the variable that was created in the workspace by a previous run of your code. Change your code, clear the variable, then run the updated code.
Luca Ferro
le 17 Mai 2023
You cannot name a variable with the same name as a built-in matlab function.
Change the line det=det(A) to something else like detA=det(A).
3 commentaires
Luca Ferro
le 22 Mai 2023
exactly. use this before rerunning the script.
clear det
i would not use clear all since there may be variables you want to keep in the workspace.
Image Analyst
le 19 Mai 2023
Type
clear all;
to get rid of your "det" that you created previously, and then run your code either in a script or the command window.
clear all;
A = [1 2 3; -4 1 2; 0 9 -8];
B = [12; 13; -1];
solution = A\B
detA = det(A)
0 commentaires
Voir également
Catégories
En savoir plus sur Linear Algebra 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!