Array indices must be positive integers or logical values.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Irem ERSIN
le 18 Déc 2021
Commenté : Irem ERSIN
le 18 Déc 2021
I am trying to do app design for forward kinematics of 6 dof robot arm. How can I fix that error?
2 commentaires
Réponse acceptée
Walter Roberson
le 18 Déc 2021
In MATLAB, the form
A(stuff) = B
can have two different meanings.
In the case that stuff evaluates to a symbolic variable or vector of symbolic variables, then it would create a symbolic function named A whose parameters were the symbolic variable(s) and whose body is the result of evaluating the right hand side. For example
syms x
f(x) = sin(x) + x^2
is the same as
syms x
f = symfun(sin(x) + x^2, x)
Otherwise, when stuff is not symbolic then
A(stuff) = B
means that if a variable in scope named A already exists, then its values at the indices in stuff are to be assigned whatever is in B. If no variable in scope exists then A is to be created as a variable first and given the same types as B, and then the assignment is to take place.
So where you have
num2str(floor(T.t(1)) = something
that would mean that a variable named num2str should be created and should be indexed at location given by floor(T.t(1)) and that location is to be assigned whatever is on the right.
If the result of floor() were all positive integers then the indexing would be valid and the assignment could take place. But if the results floor() was 0 or negative then the assignment would fail.
It is highly likely that the reader will get confused by assignments to a variable named num2str and that is to be avoided.
2 commentaires
Walter Roberson
le 18 Déc 2021
I think you might have left and right sides reversed! A=B evalutes B and assigns into A; I think you expected the left side to be assigned to the right.
Walter Roberson
le 18 Déc 2021
Note that edit fields in app designer can be created as numeric, in which case you would assign their Value property a numeric value instead of a string or character vector
Plus de réponses (1)
Matt J
le 18 Déc 2021
You must examine the contents of floor(T.t(3)). It is zero, which is not a valid index.
0 commentaires
Voir également
Catégories
En savoir plus sur Robotics System Toolbox 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!