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

3 次查看(过去 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 个)

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