Java slider not Responding

2 visualizaciones (últimos 30 días)
Lawson Hoover
Lawson Hoover el 12 de Dic. de 2012
The slider is saved as S.sl1 and I convert it to sl1 and output it. I then convert it to a java slider in another function with :
jScrollBar = findjobj(sl1);
jScrollBar.AdjustmentValueChangedCallback = @updateplot;
Then the call back function is:
function updateplot(sl1,ht,funcNum)
x = get(sl1,'Value');
Beam.Location = x;
switch funcNum
case funcNum == 1
y = Cantilieverd_Point(Beam);
case funcNum == 2
y = Simple_Point(Beam);
Where ht is the plot that is being updated and the ' y = ' is another function which creates the y value. When I run this it does not return an error, but it also does absolutely nothing to the graph. I want it to continuously update the graph based off of the slider value.
  5 comentarios
Lawson Hoover
Lawson Hoover el 12 de Dic. de 2012
@ Matt Fig, well the Listener did work in a way. It would update once and then not run again. To tell you the truth I might just move on past this and come back to it later. I am still very new to MATLAB and still trying to get a hold of the concepts.
Malcolm Lidierth
Malcolm Lidierth el 12 de Dic. de 2012
Editada: Malcolm Lidierth el 12 de Dic. de 2012
@Lawson That is a vital bit of info. The callback is evaluated once, throws an exception and gets removed by MATLAB. You need something like:
jScrollBar.AdjustmentValueChangedCallback = {@updateplot, ht, funcNum};
The callback should then be declared as:
function updateplot(sl1,EvenData, ht, funcNum)
sl1 and EventData are added automatically to the inputs by MATLAB>

Iniciar sesión para comentar.

Respuestas (1)

Jan el 12 de Dic. de 2012
There are several problems in your code:
1. Here the callback is defined with no inputs:
jScrollBar.AdjustmentValueChangedCallback = @updateplot;
But in the definition of the callback function, 3 inputs are required.
2. Look at the documentation of switch/case again. The term "funcNum==1" is evaluated to either true or false, but you want to switch for the value 1 or 2. Therefore you need:
switch funcNum
case 1 % Not "funcNum == 1"
I suggest not to use a Java slider, but the standard Matlab sliders. You cann attach a listener to them also:


Más información sobre Startup and Shutdown en Help Center y File Exchange.


Community Treasure Hunt

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

Start Hunting!

Translated by