Help writing a function

조회 수: 2 (최근 30일)
Jay
Jay 2016년 11월 5일
답변: Walter Roberson 2016년 11월 5일
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