how can i correct this error here "??? Error using ==> eq Matrix dimensions must agree."????

1 visualización (últimos 30 días)
Hi all, i tried to implement this code in matlab ,but i obtained this error"??? Error using ==> eq Matrix dimensions must agree." please i need a help in solving this error .i know that this error begins from featuretest because of its size will be 85*200 instead of 85*40,and this will affects the size of val and poz because of their size will be 200*1 instead of 40*1 and therefore using find here returned me this error , how can can i correct this code to solve this problem ?? help me please.
close all
N2=85*1;
nr_classes = 40;
nr_train = 4;
no_of_images= nr_classes * nr_train;
featurestrain=zeros(N2,no_of_images);
for i = 1:nr_classes
for j = 1:nr_train
if(i<10)
nume=strcat('remove_smallobjects25\000',num2str(i),'hv',num2str(j),'.bmp');
else
nume=strcat('remove_smallobjects25\00',num2str(i),'hv',num2str(j),'.bmp');
end
imag = double(imread(nume,'bmp'));
imag = imresize(imag,0.05);
[features]=feature_extractoion_zoingmodification(imag);
end
featurestrain(:,nr_train *(i-1)+j)=features;
end
clear features
k = 1;
for i = 1:nr_classes
for j = 1:nr_train
k=k+1;
end
mean_TrainingVectors(:,i) = mean(featurestrain(:,k-4:k-1),2);
end
[KL, eigen_values, eigen_vectors] = Compute_PCA(featurestrain);
for dim = 1:length(eigen_values)
energy(dim) = (sum(eigen_values(1:dim)))/(sum(eigen_values(1:length(eigen_values))))*100;
end
nr_features = find(energy >95);
nr_features = nr_features(1);
train_PCA = KL*mean_TrainingVectors;
train_PCA = train_PCA(1:nr_features,:);
clear TrainingVectors mean_TrainingVectors
featurestest=zeros(N2,nr_classes);
for i = 1:nr_classes
for j = nr_train+1:nr_train+1
if(i<10)
nume = strcat('remove_smallobjects25\000',num2str(i),'hv',num2str(j),'.bmp');
else
nume = strcat('remove_smallobjects25\00',num2str(i),'hv',num2str(j),'.bmp');
end
imag = abs(double(imread(nume,'bmp')));
imag = imresize(imag,0.05);
[features]=feature_extractoion_zoingmodification(imag);
end
featurestest(:,((nr_train+1)*(i-1))+j)=features;
end
test_PCA = KL*featurestest;
test_PCA = test_PCA(1:nr_features,:);
for i = 1:size(test_PCA,2)
for j = 1:size(train_PCA,2)
dist_measure(i,j) = sqrt(sum(abs(test_PCA(:,i)-train_PCA(:,j)).^2));
end
end
[val, poz] = min(dist_measure,[],2);
labels = [1:nr_classes]';
disp ('recognition score [%]')
score = length(find(poz==labels))/nr_classes * 100

Respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by