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 Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by