PLEASE HELP ME WITH THIS CODE

2 visualizzazioni (ultimi 30 giorni)
jimy george
jimy george il 6 Gen 2014
Commentato: jimy george il 7 Gen 2014
srcFiles = dir('C:\Users\Delna_Jose\Documents\MATLAB\database\*.png'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = strcat('C:\Users\Delna_Jose\Documents\MATLAB\database\',srcFiles(i).name);
A = imread(filename);
k1=size(A)
A1=imresize(A,[28 28])
B=char(A1)
k2=size(B)
k3=(reshape(B,1,2352)')
t0(:,i)=k3
k4=size(t0)
% figure, imshow(A);
end
t0v=t0(:,1:5)
t0w=t0(:,6:10)
t0x=t0(:,11:15)
t0y=t0(:,16:20)
t0z=t0(:,21:25)
EUCLEDIAN-METHOD====================================
Dim_Red= 24;%Number of dimension
Accu=[];
Error=[];
A=[];
%Dimensionality reduction using PCA
[Vecs(:,:,1),Mean(:,1),Projec0] = abn_pca(t0v,Dim_Red);
[Vecs(:,:,2),Mean(:,2),Projec1] = abn_pca(t0w,Dim_Red);
[Vecs(:,:,3),Mean(:,3),Projec2] = abn_pca(t0x,Dim_Red);
[Vecs(:,:,4),Mean(:,4),Projec3] = abn_pca(t0y,Dim_Red);
[Vecs(:,:,5),Mean(:,5),Projec4] = abn_pca(t0z,Dim_Red);
%[Vecs(:,:,6),Mean(:,6),Projec5] = abn_pca(t55,Dim_Red);
%[Vecs(:,:,7),Mean(:,7),Projec6] = abn_pca(t66,Dim_Red);
%[Vecs(:,:,8),Mean(:,8),Projec7] = abn_pca(t77,Dim_Red);
%[Vecs(:,:,9),Mean(:,9),Projec8] = abn_pca(t88,Dim_Red);
%[Vecs(:,:,10),Mean(:,10),Projec9] = abn_pca(t99,Dim_Red);
%%%**********************************************************************
%%%..........FUNCTIONAL IMPLEMENTATION OF PCA FOR K-NN & EUCLEDIAN........
%%%**********************************************************************
function [base,mean,projX] = abn_pca(Xd,k)
[xdim,N] = size(Xd);
mean = sum(Xd,2)/N;
Xd = Xd-repmat(mean,1,N);
cov = Xd*Xd'/N;
[ev,ed]=eig(cov);
ed = diag(ed);
[foo,p]=sort(-ed);
ed = ed(p);
ev = ev(:,p);
base = ev(:,1:k);
projX = base'*Xd;
%%========================================================================
%%$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.....END.....$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
%%========================================================================
THE ERROR FOUND IS
Error: File: final.m Line: 82 Column: 1
Function definitions are not permitted in this context.

Risposta accettata

Walter Roberson
Walter Roberson il 6 Gen 2014
You need to take the part from "function" to the end of file, and move it to a file named abn_pca.m

Più risposte (0)

Categorie

Scopri di più su Dimensionality Reduction and Feature Extraction in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by