如何在MATLAB中为符号变量赋予数字? [英] How can I give a number to a symbolic variable in MATLAB?
本文介绍了如何在MATLAB中为符号变量赋予数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用以下代码在MATLAB中声明一个符号变量:
I try to declare a symbolic variable in MATLAB with this code:
syms a;
我对此变量进行计算,一切都很好.但是我的问题是,我不知道如何给变量赋一个数字并以数字的形式获得结果.例如,我的代码的答案是
I do my computation on this variable and all thing is fine. But my problem is that, I don't know how can I give a number to variable and get the result as a number. For example the answer of my code is
answer=exp(-10*a);
例如,我想给"a"赋予40并得到答案
For instance I want to give 40 to "a" and get the answer as
answer =
1.9152e-174
我真的很感谢任何建议.
I really appreciate any suggestion.
推荐答案
使用评估
syms a;
answer = exp(-10*a);
a=40;
eval(answer)
ans =
1.9152e-174
这篇关于如何在MATLAB中为符号变量赋予数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文