![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1250097/image.gif)
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?
댓글 수: 0
답변 (1개)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1250097/image.gif)
I hope this helps.
댓글 수: 1
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 Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!