change GUI result automatically

1 visualización (últimos 30 días)
Muammar
Muammar el 3 de Mayo de 2012
Hii... I need help about GUI, because I am just a beginner in MATLAB. I have a simple calculation, say a+b=c. I use slider to change the value of "a" and "b". Here I want the value of "c" changes automatically when I press left arrow or right one of the slider ( either "a" or "b"), without clicking a button.
Thank you very much Muammar
  2 comentarios
Jan
Jan el 3 de Mayo de 2012
Asnwering is easier, if you ask an explicit question. What have you done so far?
Muammar
Muammar el 3 de Mayo de 2012
I did like a water flow in a tank, from 2 sources. The water volume should be the 'c', 2 sources should be 'a' and 'b', and i used a push button to recalculate the volume, but i change 'a' and 'b' used slider. that i want is, when i change the value of 'a' and 'b' using slider, the value of 'c' will automatically change.
Thank you very much,
Muammar

Iniciar sesión para comentar.

Respuestas (3)

jeff wu
jeff wu el 3 de Mayo de 2012
did u make it with guide or did you write the gui? you have do give the element that shall change something a callback function like
uicontrol('style','pushbutton',... %some other options,...
  1 comentario
Muammar
Muammar el 3 de Mayo de 2012
I used 3 edit text for a,b,c and 2 slider for a and b. I have made another push button to calculate that, but is it possible get the result without the pressbutton? I dont know about uicontrol.
Thank you

Iniciar sesión para comentar.


jeff wu
jeff wu el 3 de Mayo de 2012
i wast finischt there actually,
..., 'Callback',@myfunction);
then you write somewhere else the function:
function myfunction(~,~) here you write the code for the sum c = a+b; and then with the set method you change the valu in the uicontrol where c is written in end
i hope this was understandable,
i would need your code to be more explicit
best regards, jeff

Jan
Jan el 3 de Mayo de 2012
You can insert the callback of the pushbutton as callback of the sliders also. The slider callbacks are called, when the slider position changes. Then you can update the value of "a" or "b" at first and afterwards call the function, which triggers the calculation.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by