필터 지우기
필터 지우기

Integration with gui. convert string to sym or syms.

조회 수: 2 (최근 30일)
oner
oner 2012년 12월 6일
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));
  댓글 수: 1
oner
oner 2012년 12월 6일
Thank you so much. The problem was solved thanks to you.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by