Integration with gui. convert string to sym or syms.

1 visualización (últimos 30 días)
oner
oner el 6 de Dic. de 2012
I want to do a program. I am going to do it with Gui. This gui has two edit text. I want that; when user write an function( depent on x) like x^2 + 3*x +5.
when user click pushbutton other edit text show integral of that function.
I write that codes under callback of pushbutton :
function pushbutton_calculate_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
syms x;
a = get(handles.edit1,'String');
b = sym('a');
set(handles.edit2,'String',sym(a));
I take this errors :
??? Error using ==> set
error: mxArray must be double, char, or cell
Error in ==> untitled3>pushbutton_calculate_Callback at 84
set(handles.edit2,'String',sym(a));
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> untitled3 at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)untitled3('pushbutton_calculate_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback

Respuesta aceptada

Walter Roberson
Walter Roberson el 6 de Dic. de 2012
a = get(handles.edit1,'String');
b = int(sym(a));
set(handles.edit2, 'String', char(b));
  1 comentario
oner
oner el 6 de Dic. de 2012
Thank you so much. The problem was solved thanks to you.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by