Prompt user input for table inputdlg

14 次查看(过去 30 天)
I have an issue:
I want an user defined input such as the "input" command in an m code file. But when i use the inputdlg and input a series of data it comes out as a
[11x4 char]
instead of a 11x1 variable that can be used in the rest of the code
I want the user to input a range of values from an excel sheet into the inputdlg and then that gets used in the rest of the code.
I hope this makes sense.
  2 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2014-1-12
post your code, and explain your problem?
Jonathan Wilson
Jonathan Wilson 2014-1-13
rho = input('Enter density of operating fluid = ')
w = input('Enter Taylor wake fraction = ')
t = input('Enter Thrust deduction factor = ') D = input('Enter diameter range in meters = ')
V = inputdlg('Enter speed range','Input', 10)
T = inputdlg('Enter correspondin T using speed range','Input', 10)
This is my code, this means that the user has to input 10 numbers for the V and the T variable.
when this happens i see: [11x4 char] instead of [10x1] which is what i want to see.
I want to input a number, e.g. 469 and for that ot be a single number in a list. but what looks like is happening is, it is taking each sinlge number as seperate. e.g. 4 5 9 = [1x3] rather than [1x1]

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2014-1-13
inputdlg() always returns a cell array of strings. You can use str2double() to parse each line if you are expecting exactly one value per line. See Example 2 in http://www.mathworks.com/help/matlab/ref/inputdlg.html
  2 个评论
Jonathan Wilson
Jonathan Wilson 2014-1-14
So what does str2double use?
I want to enter a range of values for example
456.9
345.7
302.6
...
...
...
...
...
...
...
...
then there to be a matrix of 10x1 not 10x6 as it splits the numbers up individually.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by