Wanting to call a number from a 1x6 double
12 次查看(过去 30 天)
显示 更早的评论
In my code Im calculating inverse kinematics where:
J = bot.ikine(T, [0 0 0], [1 1 1 1 1 0 0 0]) *180/pi
In the workspace J is labelled as a 1x6 double
and in the command window J outputs 6 different number like so:
J =
9.4623 -71.4600 -21.3836 0.0000 -50.0763 -9.4623
Im trying to print the seperate values on a GUI so for example Theta 1 will display 9.4623, theta 2 will display -71.4600 etc ...
However when I try to select a number from J:
J(1,6)
this displays -9.4623 when I throught it would display 9.4623
also when i then try to select the second number from J:
J(2,6)
I get the following error
Index in position 1 exceeds array bounds (must not exceed 1).
Does anyone have an idea how i can reference to each number within J?
1 个评论
Stephen23
2022-8-1
编辑:Stephen23
2022-8-1
"However when I try to select a number... J(1,6)... this displays -9.4623 when I throught it would display 9.4623"
The sixth value in the first row is -9.4623. You did not explain why you think it should be something else.
"also when i then try to select the second number ...J(2,6) ... I get the following error "
The array J has only one row: what do you expect to occur when you try to access an element from a row that does not exist?
"Does anyone have an idea how i can reference to each number within J?"
Because your data are in a vector, linear indexing is sufficient, e.g.:
J(2)
J(6)
采纳的回答
Dennis
2022-8-1
Your array has the size 1x6. So it contains values at the positions (1,1) = 9.4623, (1,2) = -71.4600, (1,3) = -21.3836 and so on.
You can either try J(1,1), J(1,2) ... to get your 6 values or J(1), J(2) will also work.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!