I´m reviewing code from __Toronto perceptron MATLAB code__

The code is

function [w] = perceptron(X,Y,w_init) w = w_init;

for iteration = 1 : 100 %<- in practice, use some stopping criterion!

for ii = 1 : size(X,2) %cycle through training set if sign(w'*X(:,ii)) ~= Y(ii) %wrong decision? w = w + X(:,ii) * Y(ii); %then add (or subtract) this point to w end end sum(sign(w'*X)~=Y)/size(X,2) %show misclassification rate end

So I was reading how to apply this function to data matrix X, and target Y, but, do not know how to use this function, I understand, it returns a vector of weights, so it can classify.

Could you please give an example, and explain it??

I´ve tried

X=[0 0; 0 1; 1 1] Y=[1 0; 2 1] w=[1 1 1] Result = perceptron( X, Y, w ) ??? Error using ==> mtimes Inner matrix dimensions must agree. Error in ==> perceptron at 15 if sign(w'*X(:,ii)) ~= Y(ii) Result = perceptron( X, Y, w' ) ??? Error using ==> ne Matrix dimensions must agree. Error in ==> perceptron at 19 sum(sign(w'*X)~=Y) / size(X,2);

Thanks

Thank you for the answers, I got one more, If I change the Y = [0, 1], what happens to the algorithm?.

**So, Any input data will not work with Y = [0,1] with this code of the perceptron right?**