필터 지우기
필터 지우기

why dosen't out put as short answer?

조회 수: 3 (최근 30일)
sadiqah aldahan
sadiqah aldahan 2022년 4월 15일
댓글: Walter Roberson 2022년 4월 16일
syms y
R1=(nthroot(y-2,3)+2);
R2=y;
R3=1;
eq1=int(R1^2,y,1,2.1);
eq2=int(R2^2,y,2.094,4);
eq3=int(R3^2,y,0,1);
format short
volume=(eq1+eq2+eq3)*pi
volume = 

채택된 답변

Star Strider
Star Strider 2022년 4월 16일
Because it is symbolic, not numeric.
To get a numeric result use either vpa or double
syms y
R1=(nthroot(y-2,3)+2);
R2=y;
R3=1;
eq1=int(R1^2,y,1,2.1);
eq2=int(R2^2,y,2.094,4);
eq3=int(R3^2,y,0,1);
format short
volume=(eq1+eq2+eq3)*pi
volume = 
vpa_volume = vpa(volume)
vpa_volume = 
67.308283557712918056555924159997
double_volume = double(volume)
double_volume = 67.3083
If you want to always have this sort of result, see the documentation on sympref, and specifically Display Symbolic Results in Floating-Point Format.
.
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 4월 16일
The purpose of solve() and int() are to return indefinitely precise answers whenever possible. solve() avoids approximate numeric solutions, and int() never uses approximate numeric solutions. If you int() and the exact theoretical solution is then int() will return that, not 1.236<something>
If what you want is a numeric approximation then you should be reconsidering whether you should be using int() at all: perhaps you should be using the pure-numeric integral() or perhaps you should be doing extended precision numeric approximation using vpaintegral()

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by