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!