GUI derivative calculator, issues with coding portion
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello All,
I am trying to do my final MATLAB project and it involves creating a GUI that can handle second order differential equations. Firstl I have been trying to figure out how to make a simple derivative GUI calculator, one that can handle something from the user say 4X and when a button is pushed will spit out its derivite, 4. So far I have made the GUI and have been trying to add some code. I am new to MATLAB and some of the errors are confusing. I will post parts of the code along with my logic below:
let me define some things to make it easier to understand.
I have an edit text box whose tag line is FCN (this is the box the user will enter the derivative that needs to be taken)
I have a push button whose tag line is equal
I have a static text box whose tag line is first (this is where the answer will pop out)
I wrote a few lines of code under the equal callback:
function equalPushButton_Callback(hObject, eventdata, handles)
% hObject handle to equalPushButton (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.FCN,'string'));
b=str2sym(diff(a)); %Or b=double(b)?
set(handles.first,'string',sym2num(b));
I am wondering if someone can steer me in the right direction
Thanks
3 Kommentare
Murugan C
am 8 Mai 2019
Hi
I think, we shouldn't use "syms" for derivative .we have create one more edit box for getting derivative as like below,
f = get(handles.FCN,'String');
x = str2double(get(handles.derivative,'String')); % derivative order
der=diff(f,x);
set(handles.first,'String',char(der));
Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Identification finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!