Converting symfun to function handle
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
syms a(t) b(t)
eq = a*b;
Now, I need to take matlabFunction() of the equation, such that the whole a(t) and b(t) get replaced. I tried:
matlabFunction(eq,"vars",[a b])
But fair enough, a and b are not symbolic variables, they are symfun. Is ther a workaround to this?
I also tried the following:
matlabFunction(eq,"vars",[formula(a) formula(b)])
But appearently, the elements of vars are no longer good enough variables.
0 commentaires
Réponses (1)
Walter Roberson
le 8 Nov 2022
If you want to "demote" a and b from functions to variables then you can subs() variables into the expression.
If you want have redefined a and b since the time you created a*b and you want to incorporate the new definitions then subs()
If you want to create a function handle that accepts function handles as its arguments and applies them, such as
c = a*b
intended to translate into
C = @(a, b) @(x)a(x).*b(x)
Then that is not something you can do through matlabFunction.
2 commentaires
Voir également
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!