Why is this variable still undefined in GUI?

조회 수: 1 (최근 30일)
Veronika
Veronika 2017년 2월 15일
답변: Jan 2017년 2월 15일
Dear all,
I have GUI and I have a problem with variable shape. This error:
Undefined function or variable "shape".
Error in DP_segment_final>pushbutton5_Callback (line 383)
shape.thorax = fourier_fit(fourier_fit(shape.thorax, Ncomps), linspace(0, 1, Npts1));
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in DP_segment_final (line 44)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)DP_segment_final('pushbutton5_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I attach my code, figure and my original image. Thank you for your answers.

답변 (1개)

Jan
Jan 2017년 2월 15일
The variable is properly created some lines above:
tmp = bwboundaries(handles.binaryImage_okoli);
shape.thorax = tmp{1};
But this code is not called, if 'okraje_modelu.mat' is existing. Then:
if 2==exist ('okraje_modelu.mat')
load ('okraje_modelu')
disp('Okraje modelù byly naèteny.')
Reading the code you cannot predict, what the load command injects in the workspace. Therefore it is much clearer and safer, to catch the output:
Data = load ('okraje_modelu');
shape = data.shape;
Then you will get a useful error message in case of a missing variable.
You can use the debugger to examine, what's going on. Set a breakpoint in the first line of the callback and step through the code line by line. Check in the Workspace Browser, of the wanted variable occurres.

카테고리

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