Select a radiobutton.Calculate derivation or integration.

조회 수: 2 (최근 30일)
oner . 2012년 12월 6일
I did a can calculate function. Than function is written by user in an edit text.My gui shows it at second edit text. problem is this. My gui has two radio button(derivation and integration). I want when user select one of them my program calculate function.if user select integration my program solves integration of function, if user select derivation my progtam solves derivation of function. What i can do ? My progtam :
% --- Executes when selected object is changed in uipanel1. function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)
if(hObject == handles.radiobutton_derivation)
elseif(hObject == handles.radiobutton_integration)
% Update handles structure guidata(hObject, handles);
% hObject handle to the selected object in uipanel1 % eventdata structure with the following fields (see UIBUTTONGROUP) % EventName: string 'SelectionChanged' (read only) % OldValue: handle of the previously selected object or empty if none was selected % NewValue: handle of the currently selected object % handles structure with handles and user data (see GUIDATA)
What must i write in if and elseif ??
Thank you for answer.

채택된 답변

Matt Fig
Matt Fig 2012년 12월 7일
편집: Matt Fig 님. 2012년 12월 7일
If you put the code in SelectionChangeFcn, then the integral or derivative will be computed as soon as the user changes radio buttons. Is that really what you want?
If not, I would put the code in the callback where the calculation is made. For example in a pushbutton callback. Here is where you find the selectedobject property and use that in the IF statement.
a = get(handles.edit1,'String');
H = handles;
if H.radiobutton_derivation==get(H.uipanel1,'selectedob')
b = diff(sym(a));
b = int(sym(a));
set(handles.edit2, 'String', char(b));
  댓글 수: 6
oner 2012년 12월 7일
İt is perfect example. I examined it. I understand my problem. thank you so . i did it :)

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

추가 답변 (0개)


Help CenterFile Exchange에서 Programming Utilities에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by