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

1 次查看(过去 30 天)
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.

采纳的回答

Stephen23
Stephen23 2017-4-18
编辑:Stephen23 2017-4-18
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 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by