Info

This question is closed. Reopen it to edit or answer.

So this code when ran as a script works

1 view (last 30 days)
Alvaro Salme
Alvaro Salme on 1 Jun 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
So this code when ran as a script works just fine and gives me numerical answers
syms x y z
eqn1= x + y + z == 3;
eqn2= 2*x + 3*y + 7*z == 8;
eqn3= 5*x + 9*y + 8*z == 5;
S = solve(eqn1, eqn2, eqn3)
M = [S.x, S.y, S.z]
but when i try making a GUI so i can type the equations
syms x y z
eqn1=get(handles.edit1, 'String');
eqn2=get(handles.edit2, 'String');
eqn3=get(handles.edit2, 'String');
S = solve(eqn1, eqn2, eqn3)
M = [S.x, S.y, S.z]
i get this error
Warning: The solutions are parametrized by the
symbols:
z1 = C_
> In solve at 190
In tresxtres>pushbutton1_Callback at 157
In gui_mainfcn at 96
In tresxtres at 42
In @(hObject,eventdata)tresxtres('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
S =
x: [1x1 sym]
y: [1x1 sym]
z: [1x1 sym]
M =
[ 4*z1 + 1, 2 - 5*z1, z1]
what needs to be done so i can get a numerical answer?
  1 Comment
Walter Roberson
Walter Roberson on 2 Jun 2015
I don't know if it will fix the problem, but it would be better to use
eqn1 = sym(get(handles.edit1, 'String'));
eqn2 = sym(get(handles.edit2, 'String'));
eqn3 = sym(get(handles.edit2, 'String'));
In the future, solve() will no longer be able to solve() strings, so you will need something like this eventually anyhow. And it gives you an opportunity to display the equations to be sure they are what you think they should be.

Answers (0)

Community Treasure Hunt

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

Start Hunting!