Make a rotation matrix from a function

Hello i have this function which inputs (phi,theta,psi) and returns a
rotation matrix R
I want to use this function to create a rotation matrix in my main file with
self chosen rotation angles.
Here is the function:
function R = euler_vinkler(phi,theta,psi)
p = phi ;
t = theta ;
s = psi ;
D = [cos(p) sin(p) 0 ; -sin(p) cos(p) 0 ; 0 0 1] ;
C = [1 0 0 ; 0 cos(t) sin(t) ; 0 -sin(t) cos(t)] ;
B = [cos(s) sin(s) 0 ; -sin(s) cos(s) 0 ; 0 0 1] ;
R = B*C*D ;
end

3 件のコメント

David Goodmanson
David Goodmanson 2018 年 9 月 27 日
This looks good. Is there a question?
Fredrik Tveita
Fredrik Tveita 2018 年 9 月 27 日
Yes i want to create the rotation matrix R, but i get this error:
Error in rotation matrix (line 2)
p = phi ;
How do i choose my value for phi? psi and theta etc?
David Goodmanson
David Goodmanson 2018 年 9 月 27 日
If you run, e.g. M = euler_vinkler(1,2,3) of course it works fine. Choice of angles depends on what you want to do, so what is it that you wish to accomplish?

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

回答 (1 件)

KSSV
KSSV 2018 年 9 月 27 日

0 投票

I think you tried to run the function..by clicking run or without providing inputs. You have to save this code in a file as function with extension .m, the name of file will be euler_vinkler.m.
Now go to the folder where this function/ file is present.
In the command window type:
R = euler_vinkler(45,90,180)
The function will be executed and your output is R.

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

質問済み:

2018 年 9 月 27 日

再開済み:

2018 年 12 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by