How can I convert symbolic function into non symbolic function.

16 vues (au cours des 30 derniers jours)
ChinUk
ChinUk le 25 Juil 2018
Modifié(e) : ChinUk le 26 Juil 2018
Hi. I am trying to make a GUI algorithm and just realize that syms (from the symbolic toolbox) is not working for the compiler.
Is there any way I can use another command or change function into non-symbolic function?
My function has the following form.
syms A E B
diff_A = diff(exp(-(pre/(exp(A)*exp(E./(k*(273.16+normal_stress)))))^B),A);
A=x(1)

Réponse acceptée

Star Strider
Star Strider le 25 Juil 2018
Use the matlabFunction function:
syms A E B pre k normal_stress
diff_A = diff(exp(-(pre/(exp(A)*exp(E./(k*(273.16+normal_stress)))))^B),A);
diff_A_fcn = matlabFunction(diff_A)
to get:
diff_A_fcn =
function_handle with value:
@(A,B,E,k,normal_stress,pre)B.*pre.*exp(-E./(k.*(normal_stress+2.7316e2))).*exp(-A).*exp(-(pre.*exp(-E./(k.*(normal_stress+2.7316e2))).*exp(-A)).^B).*(pre.*exp(-E./(k.*(normal_stress+2.7316e2))).*exp(-A)).^(B-1.0)
  2 commentaires
ChinUk
ChinUk le 26 Juil 2018
Thank you for the answer. I will try to apply it.
Star Strider
Star Strider le 26 Juil 2018
As always, my pleasure.
You will find it easier to use as:
diff_A_fcn = @(A,B,E,k,normal_stress,pre) B.*pre.*exp(-E./(k.*(normal_stress+2.7316e2))).*exp(-A).*exp(-(pre.*exp(-E./(k.*(normal_stress+2.7316e2))).*exp(-A)).^B).*(pre.*exp(-E./(k.*(normal_stress+2.7316e2))).*exp(-A)).^(B-1.0);

Connectez-vous pour commenter.

Plus de réponses (1)

KSSV
KSSV le 25 Juil 2018
How about using anonymous function?
diff_A = @(A,B,E) diff([exp(-(pre/(exp(A)*exp(E./(k*(273.16+normal_stress)))))^B),A]);
  2 commentaires
ChinUk
ChinUk le 26 Juil 2018
Thank you for your help. I really appreciate it.
ChinUk
ChinUk le 26 Juil 2018
Modifié(e) : ChinUk le 26 Juil 2018
Thank for your answer, just a little quick question.
As you see, I try to make differential function without using the syms command.
and how can I replace 'eval' command? deval function is not so useful.
the full function had the following format.
diff_A = diff(exp(-(pre/(exp(A)*exp(E./(k*(273.16+normal_stress)))))^B),A);
diff_E = diff(exp(-(pre/(exp(A)*exp(E./(k*(273.16+normal_stress)))))^B),E);
diff_B = diff(exp(-(pre/(exp(A)*exp(E./(k*(273.16+normal_stress)))))^B),B); A=x(1); E=x(2); B=x(3);
g = [eval(diff_A) eval(diff_E) eval(diff_B)];

Connectez-vous pour commenter.

Catégories

En savoir plus sur Symbolic Math Toolbox 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!

Translated by