Array indices must be positive integers or logical values.
2 次查看(过去 30 天)
显示 更早的评论
I am trying to do app design for forward kinematics of 6 dof robot arm. How can I fix that error?
2 个评论
采纳的回答
Walter Roberson
2021-12-18
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 个评论
Walter Roberson
2021-12-18
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
2021-12-18
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
更多回答(1 个)
Matt J
2021-12-18
You must examine the contents of floor(T.t(3)). It is zero, which is not a valid index.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Robotics System Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!