使用'解决'功能 [英] Using the 'solve' function
问题描述
我想求解x的方程,并且我知道至少有两个解,这意味着jj将是一个向量.我需要最大的解决方案-即max(jj)发挥了作用.但是z = max(jj) 会给我最大的数字,但它不会对其进行评估.例如z可以是= 2 * 3 ^ 4 +1.在这种形式下,我无法将此数字"发送给我要执行的其他功能. "k"是给定的数字而不是变量. (例如k = 10或其他任何数字)
I would like to solve an equation for x, and i know that there are atleast two solutions,which means that jj will be a vector. I need the largest of those solutions - that is were max(jj) comes into play. However z = max(jj) will give me the biggest number, but it does not evaluate it. for example z could be = 2*3^4 + 1 . In this form i can't send this "number" to another function which I want to do. the 'k' is a given number not a variable. (say k=10 or any other number)
syms x
eqn = x + (k/6)*(x^2 -1) ==0
jj = solve(eqn,x)
z = max(jj)
推荐答案
您正在寻找一种从符号形式转换为数字形式的方法.为此,有一个标准的符号工具箱功能:double
.
You are looking for a way to convert from symbolic to numeric form. There is a standard symbolic toolbox function for that: double
.
z1=double(z)
应以双精度格式数组返回表达式的值.
should return the value of the expression in a double format array.
这篇关于使用'解决'功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!