Integration with gui. convert string to sym or syms.

2 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2012-12-6
a = get(handles.edit1,'String');
b = int(sym(a));
set(handles.edit2, 'String', char(b));

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by