0

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?

4
  • Have you looked at the variable answer after running your code? It should contain a 2x1 cell array with your inputs. Commented Jan 12, 2019 at 18:44
  • yes but if i get the values with indexing parenthesis to answer it returns again cell array not a number Commented Jan 12, 2019 at 18:56
  • 3
    Then index the cell array using curly braces. It would help tremendously if you included the actual problem you're having in your question. There is no mention in your question of indexing with parentheses. Commented Jan 12, 2019 at 19:00
  • Please read How to Ask. Commented Jan 12, 2019 at 20:12

1 Answer 1

1

please try:

n = str2num(answer{1});
color = answer{2};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.