Define a variable via inputdlg?
4 次查看(过去 30 天)
显示 更早的评论
I would like a variable to be assigned via a user prompt. For example, consider the following command:
row = inputdlg('Insert row number.');
When a user inputs 1 in the popup box, the value of the variable "row" is not recognized as a number or a string, but as a '1', with ticks surrounding it.
Is there a way to have a variable defined as a number or a string from a popup box?
Thank you!
0 个评论
采纳的回答
更多回答(1 个)
David Sanchez
2014-1-30
You can do it in a single line and use str2double which is faster than str2num:
row = str2double( inputdlg('Insert row number.') );
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!