0

I am quiet new to matlab NN toolbox and have created the following NN network:

val.P=Exp;

net =newff(minmax(p),[20,3],{'tansig','purelin'},'trainlm');

net.trainParam.epochs = 5000;    %Max Ephocs
net.trainParam.goal = 1e-5;     %Training Goal in Mean Sqared Error
net.trainParam.min_grad = 0.05e-3;
net.trainParam.show = 50;       %# of ephocs in display
net.trainParam.max_fail =20;
net = init(net);

[net,tr]=train(net,p,t,[],[],val);
o1 = sim(net,Exp)

How can I run the above for say 20 times and store the data in one variable (o1)? Any help is very much appreciated !

1
  • Hi, Please see the revised question. Commented May 10, 2012 at 13:38

1 Answer 1

2
for iteration=1:20
  % Your NN code
  [net, tr]=train(net,p,t,[],[],val);
  o1(:,iteration) = sim(net,Exp);
end

After that, o1 will be an array with all the results in it.

Note: Since I don't know the dimensions of your data, you might need to modify o1(iteration) to o1(:,iteration) or o1(:,:,iteration) etc. Whatever you need.

Sign up to request clarification or add additional context in comments.

7 Comments

Thanks alot for the reply, but matlab gives the following error:??? o1[iteration] = sim(net,Exp); | Error: Unbalanced or unexpected parenthesis or bracket.
o1 is <3x1> after 20 iteration I want matlab to give me a <3x20> o1. I tried o1(iteration,:) = sim(net,Exp); and this is what matlab gives me ??? Subscripted assignment dimension mismatch.
Exactly what I was going to answer. Personally I would go for o1(:, iteration), that way something like sum(o1 - TestData) will give you a result for each experiment. Also o1(:,:,iteration) etc just makes more sense to me...
without the loop what does this give you: o1 = sim(net,Exp); size(o1)?
@Jia: Thank you so much. o1(:, iteration) Solved the problem.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.