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

10 次查看(过去 30 天)
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?

回答(1 个)

Imran
Imran 2023-1-3
编辑:Imran 2023-1-3
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 个评论
S. Hannan
S. Hannan 2023-11-8
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?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by