Filter löschen
Filter löschen

Prompt user input for table inputdlg

6 Ansichten (letzte 30 Tage)
Jonathan Wilson
Jonathan Wilson am 12 Jan. 2014
Kommentiert: Walter Roberson am 14 Jan. 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 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 12 Jan. 2014
post your code, and explain your problem?
Jonathan Wilson
Jonathan Wilson am 13 Jan. 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]

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 13 Jan. 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 Kommentare
Jonathan Wilson
Jonathan Wilson am 14 Jan. 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 am 14 Jan. 2014
>> str2double({'456.9'; '345.7'})
ans =
456.9
345.7

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Type Identification finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by