trplot function not plotting a 4x4 matrix

i'm trying to plot NewDist
but it gives me this error
Error in trplot (line 365)
set(hg, 'Matrix', T);
Error in Untitled3 (line 9)
trplot(NewDist,'view',[15 15])
B = [ 0 1 0 2 ; 1 0 0 4 ; 0 0 1 -6 ; 0 0 0 1];
d = transpose([5 2 6]);
disp(d)
NewDist = transl(d) * B ;
disp(NewDist)
trplot(NewDist,'view',[15 15])

回答 (2 件)

Ameer Hamza
Ameer Hamza 2020 年 4 月 4 日

0 投票

I guess you are using trplot function from Peter Corke's robotics toolbox. Your rotation matrix
[0 1 0;
1 0 0;
0 0 1];
Chang your matrix B like this
B = [ 0 -1 0 2 ;
1 0 0 4 ;
0 0 1 -6 ;
0 0 0 1];
and it will work fine.

7 件のコメント

Hassan Bosha
Hassan Bosha 2020 年 4 月 4 日
編集済み: Hassan Bosha 2020 年 4 月 4 日
Thank you , i get it
What if i'm given different matrices
should i change them all to this form and the output be the same ?
although it works on some versions of matlab like 2015b and i'm 2017b
Ameer Hamza
Ameer Hamza 2020 年 4 月 4 日
Instead of writing it manually, It is best to create the transformation matrix using the other functions provided by the toolbox. For example
B = transl([5 2 6])*eul2tr([pi/2 0 0]);
Hassan Bosha
Hassan Bosha 2020 年 4 月 4 日
and what if i'm doing something like this
P = transpose([2,3,4]);
Rot = [ 1 0 0 ; 0 cos(45) -sin(45) ; 0 sin(45) cos(45) ];
New_P = Rot * P;
trplot(New_P)
Hassan Bosha
Hassan Bosha 2020 年 4 月 5 日
Is there a way to plot that point ?
Ameer Hamza
Ameer Hamza 2020 年 4 月 5 日
@Hassa, it depends on what you are trying to do here. The matrix you gave is a 3x3 matrix, so It can just be used to do the rotation. It cannot translate the corrdinate frame.
"Is there a way to plot that point ?"
trplot is not used to draw a point. It just draws a coordinate frame at a specified location.
Hassan Bosha
Hassan Bosha 2020 年 4 月 5 日
how can i draw a point in 3d then ?
Ameer Hamza
Ameer Hamza 2020 年 4 月 5 日
Can you explain what you are trying to do. It seems like you don't need to use trplot at all. You can try a point in 3D using plot3() command
plot3(1,2,3, '+')
will draw a point at x=1, y=2, and z=3.

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

George Abrahams
George Abrahams 2023 年 12 月 14 日

0 投票

I assume that you want to plot the different coordinate systems, so that you can see the effect of your rotation.
While I'm not familiar with trplot, my plotframe function on File Exchange will do something similar.
You can see a number of examples for that here.

カテゴリ

タグ

質問済み:

2020 年 4 月 4 日

回答済み:

2023 年 12 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by