large value explanation mixing sym vars with double
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello and thanks ahead for taking the time to answer my question. Please consider the following
a = wc*((s^2+200)/(10*s)) wc is assigned the value 1.2279 and 's' is a sym var.
when I execute the above code can someone explain to me why I get these rather large coefficients? Like where did these numbers even come from?
a =
(552840675468697*(s^2 + 200))/(4503599627370496*s)
I guess it has something to do with mixing doubles with sym vars, using VPA gives me what I'm looking for:
ans =
0.12275528937093427295224046247313*s + 24.551057874186854590448092494626/s
again can someone explain to me why this is? Thanks again.
댓글 수: 0
답변 (1개)
Steven Lord
2015년 10월 23일
When you perform computations like * using a double precision value and a symbolic variable, MATLAB converts the double precision value into a symbolic value. By default it does so by converting the double precision value into a rational or "nice" form. If it can't do that, it instead converts the double precision value exactly into N*2^e (in this case, 1/4503599627370496 is 2^(-52).) See the description of the 'r' and 'f' flags in the documentation for the SYM function for additional information.
댓글 수: 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!