help for subs and sym commands ???
1 view (last 30 days)
Show older comments
Hatem Çoban
on 16 Feb 2017
Commented: Hatem Çoban
on 17 Feb 2017
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 Comments
Accepted Answer
John D'Errico
on 16 Feb 2017
Edited: John D'Errico
on 16 Feb 2017
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);
More Answers (0)
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!