Azzera filtri
Azzera filtri

A function that creates a transformation matrix

3 visualizzazioni (ultimi 30 giorni)
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 Commenti
Reuben Addison
Reuben Addison il 27 Ott 2022
They wont fall from the sky, they are in the fuction
Torsten
Torsten il 27 Ott 2022
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 ?

Accedi per commentare.

Risposte (1)

Steven Lord
Steven Lord il 27 Ott 2022
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 Commenti
Torsten
Torsten il 27 Ott 2022
Modificato: Torsten il 27 Ott 2022
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 il 27 Ott 2022
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.

Accedi per commentare.

Categorie

Scopri di più su Text Analytics Toolbox in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by