Search code examples
matlabdialoguser-input

How do I get user input of dialog box in variables in MATLAB?


I have the code below to assemble a dialog box:

prompt = {'Enter matrix size:','Enter colormap name:'};
title = 'Input';
dims = [1 35];
definput = {'20','Green'};
answer = inputdlg(prompt,title,dims,definput)

Basically I want to save in variables the inputs of the user like n=20 and color=Green. How to do that?


Solution

  • please try:

    n = str2num(answer{1});
    color = answer{2};