Help writing a function

2 次查看(过去 30 天)
Can someone please help on how to write the following function please.
I have 3 3x3 Rotation Matrices.
2 of which are Identity Matrices.
R1 = eye(3,3)
R2 = eye(3,3)
% R3 Rotation Value Kappa Pre-Cal
R3(3,3) = zeros
R3(1,1) = cos(xHat_BM(3,1))
R3(1,2) = sin(xHat_BM(3,1))
R3(2,1) = -sin(xHat_BM(3,1))
R3(2,2) = cos(xHat_BM(3,1))
R3(3,3) = 1
xHat_BM will be updated for each iteration (separate section of code)
How do I create a function so that said function grabs the xHat_BM value from the script, uses it for the rotation angle calculations (R3 elements in the function), then outputs the updated R3 matrix (M_BM)back into the script for the next iteration?
Thanks in advance.

采纳的回答

Walter Roberson
Walter Roberson 2016-11-5
function R3 = update_R3(xHat_BM)
% R3 Rotation Value Kappa Pre-Cal
R3 = zeros(3,3);
R3(1,1) = cos(xHat_BM(3,1));
R3(1,2) = sin(xHat_BM(3,1));
R3(2,1) = -sin(xHat_BM(3,1));
R3(2,2) = cos(xHat_BM(3,1));
R3(3,3) = 1;
To use: have your script call
M_BM = update_R3(xHat_BM);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Chemistry 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by