How to use GUI for the input of a function? Polynom calculator
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear all,
I worte a function file in Matlab:
Where G is a function and H as well, i is the argument which deicides which mathematical operation should be used.
No im am struggeling a bit. I want to create a gui, which is basically looking like a stanard random calculator, where i can input my G & H Function in the form '2*x^3 -2*x +3'. Then there will be a push buttons for + - * :, I mean the different operations in the gui where I Can chose my i in the function. At the at it should display the new polynom. Cheers, Felix
function POLYNOM( G,H,i)
syms x
if i == 1
Sum = expand(G+H)
elseif i == 2 Difference = expand(G-H) elseif i == 3
Product = expand(G*H)
elseif i == 4
Quotient = expand(G/H) end
end
0 Kommentare
Antworten (1)
M. A.
am 7 Jun. 2017
Bearbeitet: M. A.
am 7 Jun. 2017
For learning how to build a GUI you could start here: https://mathworks.com/help/matlab/ref/uicontrol.html
For inputting a function like you want to I'd use an Edit-type uicotrol (see link above). Let's say you callled this edit-field myedit:
myedit = uicontrol('Style','edit');
Then you could read the text in there into an anonymous function:
F = eval(['@(x) ' get(myedit,'String')]);
And use this to calculate values:
X = [1 2 3];
Y = F(X);
In your case this should be executed inside the callback functions of your +,-,*,/ pushbuttons.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!