Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.
|
|
Math Forum
»
Discussions
»
Software
»
comp.soft-sys.matlab
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
myfun: Attempted to access p(3); index out of bounds because numel(p)=2
Replies:
1
Last Post:
Nov 11, 2013 5:33 PM
|
 |
|
Jonas
Posts:
1
Registered:
11/11/13
|
|
myfun: Attempted to access p(3); index out of bounds because numel(p)=2
Posted:
Nov 11, 2013 4:56 PM
|
|
Hey, although I tried to google it, I couldn't find the right examples how to make (p)=3! Thank you for your help!
function F = myfun(p) s1 =(exp(5-p(1)))/(1+exp(5-p(1))+exp(3.5-p(2))+exp(5-p(3))); s2 =(exp(3.5-p(2)))/(1+exp(5-p(1))+exp(3.5-p(2))+exp(5-p(3))); s3 =(exp(5-p(3)))/(1+exp(5-p(1))+exp(3.5-p(2))+exp(5-p(3))); F = [s1+(p(1)-1)*(-s1)*(1-s1)+(p(2)-1)*(s1*s2); s2+(p(1)-1)*(s1*s2)+(p(2)-1)*(-s2)*(1-s2); s3+(p(3)-1)*(-s3)*(1-s3)];
p0 = [-5; -5]; options = optimoptions('fsolve','Display','iter'); [p,fval] = fsolve(@myfun,p0,options)
Attempted to access p(3); index out of bounds because numel(p)=2.
Error in myfun (line 2) s1 =(exp(5-p(1)))/(1+exp(5-p(1))+exp(3.5-p(2))+exp(5-p(3)));
Error in fsolve (line 217) fuser = feval(funfcn{3},x,varargin{:});
Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
|
|
|
|