Converting syms to double
조회 수: 6 (최근 30일)
이전 댓글 표시
Is there a way to use one variable as both syms and double at the same time? I'm running a programme in which one variable takes a double value in the first iteration and then has to give a syms value in the next iteration, but it's throwing an error because I initialised that variable as syms.
댓글 수: 0
답변 (1개)
Star Strider
2021년 9월 23일
I have no idea what you are actually doing, however converting between symbolic and double is straightforward (if inefficient in some contexts).
Example —
syms t
x = sym(42)
Il = 0;
Iu = 1;
intxt = int(x*t, Il, Iu)
fprintf('The integral of %.1f*t from %.1f to %.1f = %.2f\n', double(x), Il, Iu, double(intxt))
producing:
The integral of 42.0*t from 0.0 to 1.0 = 21.00
The online Run feature is still down for scheduled maintenance, so I cannot run that here.
.
댓글 수: 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!