vpa(Fv,5) can not consider all the terms
조회 수: 1 (최근 30일)
이전 댓글 표시
Fv = - 4.4574e-25*x^21 + 3.0044e-21*x^20 - 5.6303e-17*x^19 + 1.7379e-13*x^18 - 1.4891e-9*x^17 + 1.3636e-8*x^16 - 2.8806e-9*x^15 - 2.0262e-7*x^14 - 7.3855e-8*x^13 - 4.8971e-7*x^12 + 0.000011088*x^11 + 0.000021129*x^10 - 0.000080694*x^9 + 0.00010399*x^8 - 0.0011636*x^7 - 0.010797*x^6 - 0.00084088*x^5 - 0.2542*x^4 + 0.1897*x^3 - 2.0757*x^2 + 0.78487*x + 0.078487;
%% And Can it be arranged in ascending order (Please help!)
%% vpa(Fv,5) can not consider all the terms
Have a try!
댓글 수: 0
채택된 답변
Walter Roberson
2021년 6월 5일
It is not clear what you mean about considering all of the terms. vpa(Fv,5) looked fine to me. I did notice, though, that vpa() rounds to that number of significant digits, and perhaps what you want is to round in absolute digits.
sympref('PolynomialDisplayStyle', 'ascend')
syms x
Fv = - 4.4574e-25*x^21 + 3.0044e-21*x^20 - 5.6303e-17*x^19 + 1.7379e-13*x^18 - 1.4891e-9*x^17 + 1.3636e-8*x^16 - 2.8806e-9*x^15 - 2.0262e-7*x^14 - 7.3855e-8*x^13 - 4.8971e-7*x^12 + 0.000011088*x^11 + 0.000021129*x^10 - 0.000080694*x^9 + 0.00010399*x^8 - 0.0011636*x^7 - 0.010797*x^6 - 0.00084088*x^5 - 0.2542*x^4 + 0.1897*x^3 - 2.0757*x^2 + 0.78487*x + 0.078487
mapSymType(Fv, 'rational', @(e)round(e,5))
Is that what you were talking about?
Notice that a lot of the high-order terms are now missing, because their coefficient rounded to 5 decimal places was 0.
댓글 수: 5
Walter Roberson
2021년 6월 6일
None of the built-in MATLAB display formats will do that for you.
If you were preparing a character vector with the results, then you would have more options.
Do you need the result to be character? Do you need the result to be symbolic? Do you need to write this out to a file? Is this to be displayed in a GUI?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numbers and Precision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!