Slider or spinner changing value from an own specified array in app designer.

11 visualizaciones (últimos 30 días)
I would like the values that change when you drag a slider or Spinner in app designer to change values from a custom array.
(Slider step values from an own specified array).
Component Slider and Spinner in app designer.
For exampel an array like this, [0.01 0.12 1.23 2.03. 4.23 .... 9.99].
Can i do that? And if so, how do I do it?

Respuestas (1)

Imran
Imran el 3 de En. de 2023
Editada: Imran el 3 de En. de 2023
Hello Lars,
I understand that you want the values that change when slider or spinner is dragged, to change from a custom array.
The design of spinner or slide web widget does not allow varying the step size. It has to be constant for a particular slider or spinner. That is why step values can't be taken from a custom array.
However there is a workaround to accomplish the functionality you are looking for. We can get values from a custom array when we drag a slider or spinner. Refer to the code snippet below for the implementation details.
% Value changing function: Spinner
function SpinnerValueChanging(app, event)
changingValue = event.Value;
app.Spinner.Step = 1;
array = [0.01 0.12 1.23 2.03 4.23 9.99];
if changingValue<=size(array,2) && changingValue>=1
app.EditField.Value = array(1,changingValue);
end
end
Here, the displayed value is stored in an edit field, as an example. We can utilize the spinner value as an index to the custom array. So everytime the spinner value changes, the edit field stores the value from the custom array. You can use some other way to store the output too, but general idea will remain the same.
I hope this helps.
  1 comentario
S. Hannan
S. Hannan el 8 de Nov. de 2023
Is it possible to show the value of Edit Field in the place of Spinner value? I mean is it possible to combine both of them so that instead of showing the spinner's value, the Edit Field's value is visible?

Iniciar sesión para comentar.

Categorías

Más información sobre Dialog Boxes 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