MATLAB Answers

Why my prompt (inputdlg) doesn´t work right?

7 views (last 30 days)
Dear all,
I have this part of code for option some parameteres in 3D model:
prompt = {'Nastavení výšky modelu:','Nastavení jemnosti sítě modelu:','Nastavení počtu elektrod:','Nastavení vzdálenosti mezi elektrodami:','Nastavení poloměru elektrod:','Nastavení tvaru elektrod:','Nastavení jemnosti sítě elektrod:','Nastavení kontur:'};
dlg_title = 'Nastavení parametrů modelu';
defaultans = {'1','0.8','16','1','0.05','0','0.4','256'};
num_lines = [ones(size(defaultans')) ones(size(defaultans'))*75];
answer = inputdlg(prompt, dlg_title,num_lines, defaultans);
answer = str2double(answer);
params.Height = answer{1};
params.Norm = answer{2};
params.Refi = answer{3};
params.NumEl = answer{4};
params.DistEl = answer{5};
params.RadEl = answer{6};
params.ShapeEl = answer{7};
params.RefiEl = answer{8};
params.Norm = answer{9};
But if I would like to change the number, this error appears:
Cell contents reference from a non-cell array object.
Error in DP_segment_final>Okoli_Callback (line 420)
params.Height = answer{1};
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in DP_segment_final (line 44)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)DP_segment_final('Okoli_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
Can you advice me, what´s wrong?
Thank you for your answers.

  0 Comments

Sign in to comment.

Accepted Answer

Stephen Cobeldick
Stephen Cobeldick on 18 Apr 2017
Edited: Stephen Cobeldick on 18 Apr 2017
After str2double the variable answer is a double, not a cell array, so you need to access its values using normal parentheses:
params.Height = answer(1);
..etc

  0 Comments

Sign in to comment.

More Answers (0)


Translated by