'Undefined function or variable ' error but variable is defined in function working in GUI
14 views (last 30 days)
Show older comments
Tomas Pechac
on 12 Mar 2018
Answered: Fangjun Jiang
on 12 Mar 2018
So I have another problem with GUI. Like I said, I've perfectly working code but when I tried to get it into GUI I get this error:
Undefined function or variable 'h'.
Error in untitled>FILT_IMG_Callback (line 105)
f=(h-1)/2; % padding value for window: f=1; f=2; f=3; f=4; f=5;
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in untitled (line 42)
gui_mainfcn(gui_State, varargin{:});
I don't understand why I'm getting this error because variable is already defined. Here's code:
function FILT_IMG_Callback(hObject, eventdata, handles)
% hObject handle to FILT_IMG (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
X = getappdata(0,'X');
A = rgb2gray (X);
X = A;
%setappdata(0,'filename',X);
%axes(handles.axes1);
%imshow(X);
if nargin < 2
h=3; % local search window size: h=3; h=5; h=7; h=9; h=11;
f=1; % padding value for window: f=1; f=2; f=3; f=4; f=5;
else
f=(h-1)/2; % padding value for window: f=1; f=2; f=3; f=4; f=5;
end
F = zeros(h*h,1);
Y = zeros(size(X));
X = double(padarray(X,[f f],'symmetric'));
[m n ~] = size(X);
%etc
Any ideas?
0 Comments
Accepted Answer
Fangjun Jiang
on 12 Mar 2018
if nargin < 2
h=3; % local search window size: h=3; h=5; h=7; h=9; h=11;
f=1; % padding value for window: f=1; f=2; f=3; f=4; f=5;
else
f=(h-1)/2; % padding value for window: f=1; f=2; f=3; f=4; f=5;
end
if nargin>=2, then h is not defined.
0 Comments
More Answers (0)
See Also
Categories
Find more on Programming Utilities in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!