Filter löschen
Filter löschen

How to add inputdlg to my code for taking input ?

6 Ansichten (letzte 30 Tage)
D KUSHAL KUMAR
D KUSHAL KUMAR am 3 Feb. 2019
Bearbeitet: Stephen23 am 3 Feb. 2019
%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;

Akzeptierte Antwort

Stephen23
Stephen23 am 3 Feb. 2019
Bearbeitet: Stephen23 am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by