필터 지우기
필터 지우기

how to change the precision of symbolic variables.

조회 수: 1 (최근 30일)
Sumit dash
Sumit dash 2019년 10월 1일
댓글: Star Strider 2019년 10월 1일
s^3*246655351680430349161861489360895748665691918000757954295365632i - s^2*(36212255157820456428489768408649977023491870935380775514669056 + 578091697775954585022159881976519846765626019509350787237019648i) - s*(130062300639770074374222879395026417216202027377365642475732992 + 861105664727459103565145461543508318180271162190507702581460992i) - (223478472834610436324352002622703850555766990429849990494534772 + 585856833391770884939511626951491940256735302346867433027453683i)
I need it to be 6 digit precised.

답변 (1개)

Star Strider
Star Strider 2019년 10월 1일
Use the vpa function:
syms s
p = s^3*246655351680430349161861489360895748665691918000757954295365632i - s^2*(36212255157820456428489768408649977023491870935380775514669056 + 578091697775954585022159881976519846765626019509350787237019648i) - s*(130062300639770074374222879395026417216202027377365642475732992 + 861105664727459103565145461543508318180271162190507702581460992i) - (223478472834610436324352002622703850555766990429849990494534772 + 585856833391770884939511626951491940256735302346867433027453683i);
p_vpa = vpa(p, 6)
producing:
p_vpa =
s^3*2.46655e+62i - s^2*(3.62123e+61 + 5.78092e+62i) - s*(1.30062e+62 + 8.61106e+62i) - (2.23478e+62 + 5.85857e+62i)
The expression retains full internal precision, so nothing is lost.
  댓글 수: 4
Sumit dash
Sumit dash 2019년 10월 1일
when we will be using such kind of polynomials for multiple no of times, it is not possible to write everytime this code.
So is there any method where we can declare at the beginning of a program to take only 6 significant digits or 5 significant digits, but not more than that.
Star Strider
Star Strider 2019년 10월 1일
Use the digits function.
If you want to automatically determine what I call the ‘scaling factor’, use this:
scaling_factor = vpa(10.^-fix((log(coeffs(p))/log(10))))
where ‘p’ is your polynomial of interest.
Experiment to get the result you want.

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

카테고리

Help CenterFile Exchange에서 Analog Filters에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by