PLEASE HELP ME WITH THIS CODE

1 回表示 (過去 30 日間)
jimy george
jimy george 2014 年 1 月 6 日
コメント済み: jimy george 2014 年 1 月 7 日
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.

採用された回答

Walter Roberson
Walter Roberson 2014 年 1 月 6 日
You need to take the part from "function" to the end of file, and move it to a file named abn_pca.m
  1 件のコメント
jimy george
jimy george 2014 年 1 月 7 日
Thank you sir

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDimensionality Reduction and Feature Extraction についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by