Prompt user input for table inputdlg

14 visualizaciones (últimos 30 días)
Jonathan Wilson
Jonathan Wilson el 12 de En. de 2014
Comentada: Walter Roberson el 14 de En. de 2014
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 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 12 de En. de 2014
post your code, and explain your problem?
Jonathan Wilson
Jonathan Wilson el 13 de En. de 2014
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]

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 13 de En. de 2014
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 comentarios
Jonathan Wilson
Jonathan Wilson el 14 de En. de 2014
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.
Walter Roberson
Walter Roberson el 14 de En. de 2014
>> str2double({'456.9'; '345.7'})
ans =
456.9
345.7

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by