MATLAB: Program takes long time to run

datamining

I have a code below,which takes long time to run,can u tell how to process please….
Gout is my input which contains 990 rows and 4 colomns of data(990*4)
Ng=Gout
hidden_neurons =6;
epochs = 100;
wait_l = epochs*Nf;
wait_i = 0;
%h = waitbar(0,'Training Neural Network');
for i = 1:Nf
st = (i-1)*round(size(Traindata,1)/Nf)+1;
en = i*round(size(Traindata,1)/Nf);
if en>size(Traindata,1)
en=size(Traindata,1);
end
train_inp = [Traindata(1:st-1,:);Traindata(en+1:end,:)];
train_out = [Trainlabel(1:st-1,:);Trainlabel(en+1:end,:)];
test_inp = Traindata(st:en,:);
[Predicted,wait_i] = Neural1(hidden_neurons, epochs, train_inp, train_out, test_inp, wait_l, wait_i);
Training_error_NN(i,:) = sum(abs(Predicted-Trainlabel(st:en,:)));
Training_acc_NN(i,:) = accuracy(Predicted,Trainlabel(st:en,:));
end
% close(h);
pause(1);
%wait_i = 0;
%h = waitbar(0,'Testing Neural Network');
for i = 1:Nf
st = (i-1)*round(size(Testdata,1)/Nf)+1;
en = i*round(size(Testdata,1)/Nf);
if en>size(Testdata,1)
en=size(Testdata,1);
end
train_inp = Traindata;
train_out = Trainlabel;
test_inp = Testdata(st:en,:);
[Predicted,wait_i] = Neural1(hidden_neurons, epochs, train_inp, train_out, test_inp, wait_l, wait_i);
Testing_error_NN(i) = sum(abs(Predicted-Testlabel(st:en,:)));
Testing_acc_NN(i) = accuracy(Predicted,Testlabel(st:en,:));
(Testing_acc_NN')
(Testing_error_NN')
result=[fc1 Testing_acc_NN' Testing_error_NN']
end
% close(h);
pause(1);

Best Answer

you have 2 "pause" commands in the code - any idea how many times they are called?
Have you used the profiler?
profile on % then run your code
profile viewer
That will show you were your code is taking the most time.
Related Question