필터 지우기
필터 지우기

How to add inputdlg to my code for taking input ?

조회 수: 6 (최근 30일)
D KUSHAL KUMAR
D KUSHAL KUMAR 2019년 2월 3일
편집: Stephen23 2019년 2월 3일
%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;

채택된 답변

Stephen23
Stephen23 2019년 2월 3일
편집: Stephen23 2019년 2월 3일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by