フィルターのクリア

A function that creates a transformation matrix

3 ビュー (過去 30 日間)
Reuben Addison
Reuben Addison 2022 年 10 月 27 日
コメント済み: Steven Lord 2022 年 10 月 27 日
I want to create a matrix that transform a matrix into new coordinates but I am a getting an error with too many inputs
function A = to_MNI(m0n0, m0n1, m0n2, X_loc, m1n0, m1n1, m1n2, Y_loc, m2n0, m2n1, m2n2, Z_loc)
A = [m0n0 m0n1 m0n2 X_loc; m1n0 m1n1 m1n2 Y_loc;m2n0 m2n1 m2n2 Z_loc];
B = [0 0 CD 1]';
C = A*B;
end
%C_oord = to_MNI(-53.873,-15.673,62.626,0.669,-0.623,0.404,0.227,0.69,0.688,-0.707,-0.369,0.603,9.163,9.161)
  3 件のコメント
Reuben Addison
Reuben Addison 2022 年 10 月 27 日
They wont fall from the sky, they are in the fuction
Torsten
Torsten 2022 年 10 月 27 日
But not in the code you supplied.
And why do you define "values" as input to the function if the variables "values" is made of are in the function itself ?

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

回答 (1 件)

Steven Lord
Steven Lord 2022 年 10 月 27 日
function A = to_MNI(values)
Your function accepts 1 input argument. You're calling it with 14. That's not going to work.
values = {X_loc, Y_loc,Z_loc,m0n0,m0n1,m0n2,m1n0,m1n1,m1n2,m2n0,m2n1,m2n2,CD}
None of the variables inside the curly braces are defined in your function at this point so this line of code will error. If you intended it to document the order in which the elements of the values input should be interpreted then make it a comment by starting the line with the percent symbol %.
Depending on what you're trying to do the makehgtform function may be of interest to you.
  3 件のコメント
Torsten
Torsten 2022 年 10 月 27 日
編集済み: Torsten 2022 年 10 月 27 日
If you add "CD" to the list of input parameters and you call the function with 13 scalar inputs, the modified code should work.
Steven Lord
Steven Lord 2022 年 10 月 27 日
Okay, let's line up the definition and the call. The first character of each variable name in the function definition lines up with the corresponding value in your function call.
function A = to_MNI(m0n0, m0n1, m0n2, X_loc, m1n0, m1n1, m1n2, Y_loc, m2n0, m2n1, m2n2, Z_loc)
%C_oord = to_MNI(-53.873,-15.673,62.626,0.669, -0.623,0.404,0.227,0.69, 0.688,-0.707,-0.369,0.603,9.163,9.161)
You're passing in two more values (9.163 and 9.161) than you have input arguments. As Torsten said if you add CD as another input argument in the definition then you'll be closer. You also would need to remove one of the values with which you call the function.
You probably also want to return C from your function rather than returning A.

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

カテゴリ

Help Center および File ExchangeText Analytics Toolbox についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by