MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by laplace laplace
on 19 May 2013

This question is closed and may reopen in the future if edited.

i got 3x1 matrices that i wanna classify in to two groups using k fold crossvalidation method.

- i have to train a network with the patternnet algorithm
- and apply to the data the k-fold cross validation method,

Indices = crossvalind('Kfold',inputs , 5); for i=1:5 test = (Indices == i); train = ~test; for n = 1:5 net = patternnet(inputs,targets,h); %test train net.divideFcn = 'dividetrain'; net.trainParam.goal = MSEgoal; net.trainParam.min_grad = MinGrad; [net,tr] = train(net,inputs,targets); % test train bestepoch = tr.best_epoch; R2(n,h) = 1 - tr.perf(bestepoch)/MSEtrn00; end

the above code is really wrong can someone correct it? its urgent

*No products are associated with this question.*

## 3 Comments

## Greg Heath (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/76309#comment_149754

This code is not even close to being correct.

Take some time to think it through, revise, add clarifying comments and either run on one of the nndatasets or include your data and accompanying error messages.

## laplace laplace (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/76309#comment_149805

i know it is.. i just cant think smth else.. its really really urgent if you find some time i would appreciate it..

## Walter Roberson (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/76309#comment_150419

http://www.mathworks.com/matlabcentral/answers/29922-why-your-question-is-not-urgent-or-an-emergency