获取matlab显示平方根(即2 ^(1/2)而不是1.414)(Get matlab to show square roots (i.e. 2^(1/2) instead of 1.414))
我有一些简单的方程式,我想通过matlab管道。 但我希望得到确切的答案,因为这些值预计将在以后使用和简化。
现在,Matlab将sqrt(2.0)显示为1.1414而不是像我想要的那样2^(1/2) 。
我尝试打开format rat但这很危险,因为它显示sqrt(2)为1393/985没有任何警告。
有“象征性的数学”,但似乎有点矫枉过正。
我想要的是2 + sqrt(50)将返回类似2 + 5 * (2)^(1/2) ,甚至我5岁的CASIO计算器都可以做到这一点!
那么我该怎样做才能在matlab中将2 + sqrt(50)评估为2 + 5 * (2)^(1/2) ?
I have a few simple equations that I want to pipe through matlab. But I would like to get exact answers, because these values are expected to be used and simplified later on.
Right now Matlab shows sqrt(2.0) as 1.1414 instead of something like 2^(1/2) as I would like.
I tried turning on format rat but this is dangerous becasue it shows sqrt(2) as 1393/985 without any sort of warning.
There is "symbolic math" but it seems like overkill.
All I want is that 2 + sqrt(50) would return som

博主希望在MATLAB中得到平方根的精确表示,例如2^(1/2),而不是浮点数如1.414。他们尝试了`format rat`但发现可能会导致不期望的分数形式。尽管考虑使用符号数学,但认为这过于复杂。最终,根据社区建议,使用`sym`函数解决了问题,如`x=sym('2')+sqrt(sym('50'))`,这返回了期望的形式2 + 5 * (2)^(1/2)。
最低0.47元/天 解锁文章
2003

被折叠的 条评论
为什么被折叠?



