help for subs and sym commands ???
1 次查看(过去 30 天)
显示 更早的评论
if true
clc;clear;close;
format long
syms x
f=0.0000095862*((x+1.4051)^0.44267)*((6.4051-x)^5.5867);
g=diff(f,x);
g2=diff(f,2);
h=solve(g==0)
h2=solve(g2==0)
A=subs(f,x,h)
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/160806/image.jpeg)
A must be double? Why it is sym in workplace ? Besides I have some warnings; Warning: Cannot solve symbolically. Returning a numeric approximation instead.
0 个评论
采纳的回答
John D'Errico
2017-2-16
编辑:John D'Errico
2017-2-16
Why MUST A be a double? Did you not create it as symbolic? Even though the result is a "number", it can still be stored as a symbolic form, so many digits. It will be, since how does MATLAB know that at the end, you want it as a double? How does MATLAB know that you will not now do something else with A that requires symbolic computation?
For example, you compute both h and h2 along the way. Both of them are only precursors to the final value of A, yet both of them were in symbolic form too. Would you have wanted MATLAB to arbitrarily decide that h and h2 are numbers,so it should convert them in to doubles,losing all of those extra digits along the way? While it might not matter here, it surely will matter some other time.
However, nothing stops you from now converting A INTO a double, as long as it is purely numeric. Try these things:
help sym/double
A = double(A);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!