Why is this variable still undefined in GUI?
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!