what's error in this program please help me?
Show older comments
clc; clear all; z=[0.0063 0.0158 0.0064 0.0128 0.0003; 0.0005 0.0419 0.0097 0.0404 0.0965; 0.013 0.065 0.013 0.071 0.0007]; v=[0.1 0.15 0.3 0.1 -0.1 -0.3 0.5; 0.1 0.1 0.3 -0.4 0.3 0.2 0.1; 0.1 -0.15 0.3 0.2 0.12 0.32 0.1; 0.6 -0.5 0.6 0.2 0.7 0.2 0.12; -0.1 0.3 0.1 0.4 0.3 0.1 0.-2]; w=[0.1 0.15 0.3 0.1 -0.3 0.9; 1 3 -2 1 2 1; 5 3 2 12 32 1; 5 6 9 7 2 12; -7 45 4 3 8 -67; 7 8 2 -15 43 23; -15 1 7 1 54 8]; d=[15.843 58.33 0.253 0.1739 0.1187 0.1214; 28.595 40.4 0.343 0.2788 0.0531 0.0601; 15.2 41.52 0.238 0.1981 0.0405 0.0467]; d=d/58.33; c1=0.5; c2=0.1; Emax=10e-5; g1=2; g2=2; dw=0; dv=0; for l=1:500000; for f=1:3; E=0; %computation of net for i=1:7; net=0; for j=1:5; net=net+z(f,j)*v(j,i); end netf(f,i)=net; end %computation of y for i=1:7; y(f,i)=(g1/(1+exp(-1*netf(f,i))))-g1/2; end %computation of nett for i=1:6; nett=0; for j=1:7; nett=nett+y(f,j)*w(j,i); end nettf(f,i)=nett/58.33; end %computation of o for i=1:6; o(f,i)=(g2/(1+exp(-1*nettf(f,i))))-g2/2; end %computation of do(delta not) for i=1:6; do(f,i)=(d(f,i)-o(f,i))*(g2*exp(-1*nettf(f,i)))/(1+exp(-1*nettf(f,i)))^2; end %computation of delta w(dw) for i=1:6; for j=1:7; dw(j,i)=c2*do(f,i)*y(f,j); end end %updating of weight2 w=w+dw; %computation of dy for j=1:7; dy1=0; for k=1:6; dy1=dy1+w(j,k)*do(f,k); end dy1(f,j)=(g1*exp(-1*netf(f,i))/(1+exp(-1*netf(f,i)))^2)*dy1; end %computation of dv for i=1:7; for j=1:5; dv(j,i)=c1*dy(f,i)*z(f,j); end end %updating of weight 1 v=v+dv; %computation of erorr for i=1:6; E=E+0.5*(d(f,i)-o(f,i))^2; end E; end 1; end
2 Comments
John D'Errico
on 11 May 2018
Edited: John D'Errico
on 11 May 2018
Learn to format your code so it will be readable. Read this:
https://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup#answer_18099
Why do you think it does not work? What is wrong? Did an error arise? If there was an error, then show the COMPLETE text of the error.
What do you expect to see as the result?
How do we know what it is that this code should do? A block of essentially uncommented code is virtually unreadable, and it is often impossible to know what you really wanted it to do. After all, if it is doing something wrong, how can we possibly know what it SHOULD have done? We cannot read your mind, only the uncommented, undocumented code you provided.
I would point out that the words "Computation of" used repeatedly, are NOT meaningful comments when used with nothing more said. Virtually by definition, EVERYTHING in MATLAB is the computation of SOMETHING.
If you want help, then make it easy for someone to help you.
noor mehdi
on 11 May 2018
Answers (1)
Star Strider
on 11 May 2018
The error is:
Undefined function or variable 'dy'.
Error in ... (line ...)
dv(j,i)=c1*dy(f,i)*z(f,j);
One possible solution is to change ‘dy’ to ‘dy1’, since that is the only existing variable name that seems to be close.
dv(j,i)=c1*dy1(f,i)*z(f,j);
It then runs. Beyond that I have no idea what it does.
Experiment to get the result you want.
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!