我无法执行以下代码。当我运行代码时,它显示我:
Error using load
Unable to read file 'motionDB.mat': no such file or directory.
Error in: else load ('motionDB.mat');
然而,当我删除第二个“if循环”时,它正常运行。
我的代码:
user_filter='gaussian';
if(strcmpi(user_filter,'gaussian')==1)
h = fspecial('gaussian', [3 3], 1);% gauss filter
if ~exist('gaussianDB.mat')
createHistDB( num_bins,Dir,srcFiles,filter,h,num_red_bins,num_green_bins,num_blue_bins,B );
end
else load('gaussianDB.mat');
end
if(strcmpi(user_filter,'motion')==1)% motion filter
h=fspecial('motion', 20, 45);
if ~exist('motionDB.mat')
createHistDB( num_bins,Dir,srcFiles,filter,h,num_red_bins,num_green_bins,num_blue_bins, B );
end
else load('motionDB.mat');
end
有什么想法吗?提前谢谢。
答案 0 :(得分:0)
我认为您已经混淆了代码中的else
和end
语句。而不是:
if(strcmpi(user_filter,'gaussian')==1)
h = fspecial('gaussian', [3 3], 1);% gauss filter
if ~exist('gaussianDB.mat')
createHistDB( num_bins,Dir,srcFiles,filter,h,num_red_bins,num_green_bins,num_blue_bins,B );
end
else load('gaussianDB.mat');
end
尝试:
if(strcmpi(user_filter,'gaussian')==1)
h = fspecial('gaussian', [3 3], 1);% gauss filter
if ~exist('gaussianDB.mat')
createHistDB( num_bins,Dir,srcFiles,filter,h,num_red_bins,num_green_bins,num_blue_bins,B );
else
load('gaussianDB.mat');
end
end