I want to convert from symbolic variable to double variable . but i can't, help me.

조회 수: 5 (최근 30일)
>result=feval(symengine, 'solve', '[x+3*y-8=0,2*x-5*y+52=0]')
>result = [x == -116/11, y == 68/11]
>X = double(result(1,1))
>Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
Error in sym/double (line 702)
Xstr = mupadmex('symobj::double', S.s, 0);
i want to input "x == -116" to "X" which is double variable, and i have to use Mupad command. how do i convert from symbolic variable to double variable?
when i use a "solve" command, i get a symbolic value which was calculated to use "S.x" command.(S is struct, x is symbolic). when i use Mupad command, i could't use this method. i have to use script file so i have to find a solution to one's problem.
thank you.

채택된 답변

Walter Roberson
Walter Roberson 2012년 5월 18일
If you are operating at the MuPAD level, you can use subs()
For example, in MuPAD code:
result := solve([x+3*y-8=0,2*x-5*y+52=0]);
X := subs(x, result);
Y := subs(y, result);
However, your question is confusing. You say "when i use Mupad command, i could't use this method" implying you are trying to do this within MuPAD, but converting to IEEE double precision is not supported within MuPAD (as far as I can see.)
  댓글 수: 1
jaegyu kang
jaegyu kang 2012년 5월 20일
Thank you for your answer.
I get idea to solve my problem from your answer. Have a nice weekend!

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

추가 답변 (1개)

bym
bym 2012년 5월 18일
I too am confused, but maybe this will help:
syms x y
result = solve(x+3*y-8,2*x-5*y+52)
result =
x: [1x1 sym]
y: [1x1 sym]
double(result.x)
ans =
-10.5455

태그

Community Treasure Hunt

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

Start Hunting!

Translated by