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

조회 수: 1 (최근 30일)
Veronika
Veronika 2017년 4월 18일
편집: Stephen23 2017년 4월 18일
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