Wanting to call a number from a 1x6 double

12 ビュー (過去 30 日間)
Georgia McGlennon
Georgia McGlennon 2022 年 8 月 1 日
編集済み: Stephen23 2022 年 8 月 1 日
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
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
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.
  1 件のコメント
Georgia McGlennon
Georgia McGlennon 2022 年 8 月 1 日
Thank you this has solved the problem!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by