0
votes

I am currently using knn to classify images according to their writers (problem of writer recognition). I worked on a given database that contains 150 images with 100 images for training and 50 images for testing. I've extracted the characteristics of each image and I got 2 matlab matrix: traindata.mat (size 100 * 8064) and testdata.mat (size 50 * 8064). other labels matrix that contains the class of image (size image 100 * 1)

I use knn to classify images using this code:

load('traindata.mat')
load('testdata')
load('labels')

 class=knnclassify(testdata,traindata,labels)

I got this error message:

Undefined function or variable 'testdata'.

Error in Untitled2 (line 4)class=knnclassify(testdata,traindata,labels)

please someone help me to solve this problem and thank you in advance

1
Probably the variable inside testdata is not called testdata.Ander Biguri
@AnderBiguri thank you very much, this is exactly the problem I rename the variable and it workssahar

1 Answers

0
votes

As I suggested in the comments, your problem is most likely to be the actual name of the data.

When you save/load .mat files in Matlab, the name of the file is not necessarily the name of the variables inside, as often there may be more than one variable inside those files.

It looks like when you load('testdata'), the variables inside are not called testdata and therefore Matlab does not understand the knnclasify call correctly.