how can I set spinner limit range based on text box entry ?
3 ビュー (過去 30 日間)
古いコメントを表示
I have a gui with a spinner in it
I would like to input a value in a text box and use it as upper limit for the spinner
can't find a way to do it. It seems the function does not read the text entry
here is my code for the text box
function RECdurationminTextAreaValueChanged(app, event)
REC = app.RECdurationminTextArea.Value;
app.selectminuteSpinner.Limits = [0 REC];
end
and here for the spinner
function selectminuteSpinnerValueChanged(app, event)
value = app.selectminuteSpinner.Value;
end
however when I run it I get this error when I try to scroll the spinner up or down:
Error using matlab.ui.control.internal.model.PropertyHandling.validateLimitsInput (line 721)
'Limits' must be a 1-by-2 increasing array of real numbers, such as [0 100]. Use -Inf and/or Inf to indicate no bound for the lower and/or upper limit.
Error in matlab.ui.control.internal.model.AbstractNumericComponent/set.Limits (line 225)
rowVectorLimits = matlab.ui.control.internal.model.PropertyHandling.validateLimitsInput(obj, newValue);
0 件のコメント
採用された回答
Vimal Rathod
2020 年 7 月 6 日
Hi,
Firstly you could check if your text box returns which type of data. The value you get from a normal textbox is a char or string value unless it is a numerical textbox. Try using "str2double" function before assigning the spinner limits.
REC = app.RECdurationminTextArea.Value;
% assign 2nd index(Upper Limit) of limits.
app.selectminuteSpinner.Limits(2) = str2double(REC); %str2double
Refer to the following link to know more about numeric edit field
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で System Commands についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!