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
A must be double? Why it is sym in workplace ? Besides I have some warnings; Warning: Cannot solve symbolically. Returning a numeric approximation instead.

采纳的回答

John D'Errico
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);
  1 个评论
Hatem Çoban
Hatem Çoban 2017-2-17
I got it. thanks a lot for answer. Fisrtly I didn't notice but I understood my mistake after I sent this question.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by