How to add inputdlg to my code for taking input ?

3 views (last 30 days)
%max chamber in terms of hunder
%max postion of chamber in terms of tenth
% thicknes
prompt={'enter max chamber','enter position of chamber','enter thicknes'};
title={'Input'};
dims = [1 65];
definput = {'2','2','12'};
answer=inputdlg(prompt,title,dims,definput)
m=answer*0.01;
p=answer*0.1;
t=answer*0.01;

Accepted Answer

Stephen23
Stephen23 on 3 Feb 2019
Edited: Stephen23 on 3 Feb 2019
Read the inputdlg documentation: it clearly states that the output is "a cell array of character vectors containing one input per edit field, starting from the top of the dialog box". You need to access the contents of the output cell array (which will be character vectors, exactly as the documentation states):
prompt = {'enter max chamber','enter position of chamber','enter thicknes'};
dfin = {'2','2','12'};
answer = inputdlg(prompt,'Input',[1,65],dfin);
answer{1} % 1st input
answer{2} % 2nd input
answer{3} % 3rd input
If the inputs are single numbers and you want to convert them to numeric, simply use
vec = str2double(answers)
and then use indexing to access them in vec.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!