MATLAB: Select a radiobutton.Calculate derivation or integration.

buttonderivationguiguideintegrationmatlab guiradiobuttonselect

I did a guide.it 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)
end
% 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.

Best Answer

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));
else
b = int(sym(a));
end
set(handles.edit2, 'String', char(b));
Related Question