Rename arguments of generated function with `matlabFunction`
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have a script that generated matlab functions based on some kinematic calculations. I need to pair up variables in vectors as functions arguments. However, when I do this the arguments are named `in1`, `in2`, etc., which is makes the functions very inconvenient to use.
Example:
syms x1 x2 x3 f;
f = sqrt(x1^2 + x2^2 + x3^2);
x_vec = [x1; x2; x3];
matlabFunction(f, 'file', 'myfunc.m', 'vars', {x_vec});
The resulting function will be:
function f = myfunc(in1)
%MYFUNC
% F = MYFUNC(IN1)
% ...
How can I rename the function argument? (without renaming it manully in the result of course, because I will be regenerating the functions a lot.)
It is not much of a problem in this trivial example, but in my real code I have functions with five different vector inputs.
Using a vector to begin with instead of separate variables doesn't help:
x = sym('x', [3,1]);
syms f;
f = sqrt(x(1)^2 + x(2)^2 + x(3)^2);
matlabFunction(f, 'file', 'myfunc.m', 'vars', {x});
function f = myfunc(in1)
%MYFUNC
% F = MYFUNC(IN1)
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!