how can I set spinner limit range based on text box entry ?
4 次查看(过去 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!