How do I ask for a number instead of an array?

1 view (last 30 days)
Liz
Liz on 19 Jan 2012
Currently, after user input, these lines of code:
----
prompt = {'Enter new year:','Enter former year:','Enter code for side L=1 R=2:','Enter code for ref. line (t~t=1 mn=2):','Enter distance from center:','Enter former measurement:'};
dlg_title = 'Input for fluke measurement';
temp = inputdlg(prompt,dlg_title);
[yn, yf, s, r, d, f] = temp{:}
y=yn-yf
----
Produce these results: "yn =2005; yf =1998; s =1; r =1; d = 3; f =5 ; y = 1 -9 -9 -3". I would like "y=yn-yf=2005-1998" to equal "7" and not "1 -9 -9 -3". Is this possible?
Thanks for your help.

Answers (1)

Walter Roberson
Walter Roberson on 19 Jan 2012
No, inputdlg() always returns a cell array of strings. If you want to interpret them as numbers you have to convert them to numbers, such as with str2double()

Products

Community Treasure Hunt

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

Start Hunting!