How to create Input dialog box in matlab? -
i want create input dialog box in matlab. performing simple addition operation in matlab. 2 variables name, , b needed given user , performing addition c=a+b; , display in output. both , b should positive integer only. tried following:
= inputdlg({'enter positive integer (a)'}); b = inputdlg({'enter positive integer (b)'}); c=a+b;
but giving following error:
undefined function or method 'plus' input arguments of type 'cell'.
please suggest how can code above program in described way.
that's because output of inputdlg
cell array containing string; here 1-cell array.
hence need access content of cell array perform operation; example using {curly brackets} : {a}
, {b}
.
in case, since asking use number, need convert output, string, actual number matlab can use using instance str2double
, operates on cell arrays
c = str2double(a) + str2double(b)
Comments
Post a Comment