Index exceeds the number of array elements (1)

First of all I am new to Matlab and have no experience in other programming languages.
Matlab displayed no signs on the right warning bar, but the code isn't running and I can't spot the mistake.
Are there too many input requests ?...
disp('Materialien zum Auswaehlen: Aluminium, Stahl oder Titan') %Choise of materials
prompt = {'Material eingeben:','Innendurchmesser:', 'Aussendurchmesser:','Laenge des Stabes:', 'Knickfall:'}; %Set material and values
dlg_title = 'Parameter wählen';
defaultinput= {''};
user_input = inputdlg(prompt,dlg_title,1,defaultinput);
if isempty(user_input),return,end
user_material = user_input{1}; %Convert input to string
d = str2double(user_input{2}); %Convert iput zu integer
D = str2double(user_input{3});
laenge = str2double(user_input{4});
Knickfall = str2double(user_input{5});
Following Error gets displayed:
FRBA
Materialien zum Auswaehlen: Aluminium, Stahl oder Titan
Index exceeds the number of array elements (1).
Error in inputdlg (line 260)
if ~ischar(DefAns{lp})
Error in FRBA (line 7)
user_input = inputdlg(prompt,dlg_title,1,defaultinput);

 Accepted Answer

While I don't speak that language, I believe your problem is with having defaultinput as a different size to prompt.
Note the following documentation.
If you change defaultinput as follows that should sort you out
defaultinput= {'','','','','',''};

More Answers (0)

Products

Release

R2019b

Community Treasure Hunt

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

Start Hunting!