Error 'Undefined variable "hisFtrs" or class "hisFtrs".'

histFtrs = cell(6,1);
start = 1;
for i = 1 : 6
histFtrs{i} = hist(idx(start:start+size(features{i},2)),nWords)';
%normalize
histFtrs{i} = histFtrs{i}./sum(hisFtrs{i});
end
I am getting error as
Undefined variable "hisFtrs" or class "hisFtrs".
Error in checker (line 30)
histFtrs{i} = histFtrs{i}./sum(hisFtrs{i});
If anyone can help

 Accepted Answer

At least in those lines of code you haven't defined hisFtrs variable. Can it be histFtrs?? If this is not the answer please provide the full code

3 Comments

im{1} = rgb2gray(imread('C:\Users\prayag\check_500.jpg')) ;
im{2} = rgb2gray(imread('C:\Users\prayag\real2.jpg')) ;
im{3} = rgb2gray(imread('C:\Users\prayag\real3.jpg')) ;
im{4} = rgb2gray(imread('C:\Users\prayag\real4.jpg')) ;
im{5} = rgb2gray(imread('C:\Users\prayag\fake1.jpg')) ;
im{6} = rgb2gray(imread('C:\Users\prayag\fake2.jpg')) ;
detectFeatures = @(in) {detectSURFFeatures(in)};
regions = cellfun(detectFeatures,im);
extractAndTransposeFeatures = @(in,pts) extractFeatures(in,pts)';
features = cellfun(extractAndTransposeFeatures,im,regions,'UniformOutput',false);
figure;
for i = 1 : 6
subplot(3,3,i);
imshow(im{i});
hold on;
plot(regions{i});
end
%%Create a visual vocabulary with 20 words
nWords = 20;
%use kmeans for constructing the vocabulary.
[idx,centers] = kmeans([features{:}]',nWords);
%%BoF Feature Representation
histFtrs = cell(6,1);
start = 1;
for i = 1 : 6
histFtrs{i} = hist(idx(start:start+size(features{i},2)),nWords)';
%normalize
histFtrs{i} = histFtrs{i}./sum(hisFtrs{i});
end
%display histograms
figure;
for i = 1 : 6;
subplot(3,3,i);
bar(histFtrs{i});
end
%%Partition images into 2 sets using kmeans
idx = kmeans([histFtrs{:}]',2) ;
Here is the full code.
As I said before, your error is a typo in the line
histFtrs{i} = histFtrs{i}./sum(hisFtrs{i});
It should be:
histFtrs{i} = histFtrs{i}./sum(histFtrs{i});
Are you having more errors after changing this line?
Thanks Buddy , was a very silly mistake on my part.

Sign in to comment.

More Answers (0)

Products

Release

R2015b

Tags

Community Treasure Hunt

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

Start Hunting!