Skip to content

Instantly share code, notes, and snippets.

@jgillis
Last active September 22, 2022 15:54
Show Gist options
  • Save jgillis/58176f12c21680bc7e4fad4af9f33b2a to your computer and use it in GitHub Desktop.
Save jgillis/58176f12c21680bc7e4fad4af9f33b2a to your computer and use it in GitHub Desktop.
function [casadi_expr] = mupad2casadi(mupad_expr,mupad_var,casadi_var)
s = size(mupad_expr);
assert(numel(s)<=2, 'Tensors not supported. Make a vector or matrix from the mupad expression first.');
mupad_expr = mupad_expr(:);
matlabFunction(symfun(mupad_expr,mupad_var),'File','temp_fun.m');
clear temp_fun
args = vertsplit(casadi_var);
casadi_expr = temp_fun(args{:});
%casadi_expr = reshape(casadi_expr,s);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment