필터 지우기
필터 지우기

help for subs and sym commands ???

조회 수: 1 (최근 30일)
Hatem Çoban
Hatem Çoban 2017년 2월 16일
댓글: Hatem Çoban 2017년 2월 17일
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