From: Anna Zabai on 19 May 2010 10:40 I am using Matlab 7.6.0.324, and I find that I am having problems using fsolve to solve a system on two non-linear equations in two unknowns. I am relatively new to Matlab, so I apologise in advance if I seem inexperienced. I am. Basically when I call my M-file myfun.m within the main command window i.e. when I type x = fsolve(myfun,x0) I get an error message which says ??? Undefined function or variable 'myfun'. even though the function is saved in my current directory. I am not sure what I am doing wrong. I am attaching a copy of the myfun.m file. Thank you very much for your advice Anna function F = myfun(x) F = [(1+x(1)*(x(2)^2)*(1-h*cdf('Normal',sqrt(rho*k)*(h*x(2)*x(1)*(g2-(1-h/2)*x(2)*x(1))-z),0,1)))*x(1) - g1 + x(1)*x(2)*g2*(1-h*cdf('Normal',sqrt(rho*k)*(h*x(2)*x(1)*(g2-(1-h/2)*x(2)*x(1))-z),0,1)) + x(1)*sqrt(rho*k)*h*x(2)*x(1)*(g2-(1-h/2)*x(2)*x(1))*h*x(2)*(g2-(2-h)*x(2)*x(1))*pdf('Normal',sqrt(rho*k)*(h*x(2)*x(1)*(g2-(1-h/2)*x(2)*x(1))-z),0,1); h*x(2)*x(1)*(g2-(1-h/2)*x(2)*x(1) - z - sqrt(rho*(1+k))*icdf('Normal',(1-1/(x(1)*x(2)))/h,0,1) + (1+k)*sqrt(rho)*icdf('Normal',x(1)/w,0,1)];
From: Nicholas Kinar on 19 May 2010 12:08 On 10-05-19 8:40 AM, Anna Zabai wrote: > I am using Matlab 7.6.0.324, and I find that I am having problems using > fsolve to solve a system on two non-linear equations in two unknowns. I > am relatively new to Matlab, so I apologise in advance if I seem > inexperienced. I am. Basically when I call my M-file myfun.m within the > main command window i.e. when I type > > x = fsolve(myfun,x0) > > I get an error message which says ??? Undefined function or variable > 'myfun'. > even though the function is saved in my current directory. > I am not sure what I am doing wrong. I am attaching a copy of the > myfun.m file. > Thank you very much for your advice > > Anna > function F = myfun(x) > > F = > [(1+x(1)*(x(2)^2)*(1-h*cdf('Normal',sqrt(rho*k)*(h*x(2)*x(1)*(g2-(1-h/2)*x(2)*x(1))-z),0,1)))*x(1) > - g1 + > x(1)*x(2)*g2*(1-h*cdf('Normal',sqrt(rho*k)*(h*x(2)*x(1)*(g2-(1-h/2)*x(2)*x(1))-z),0,1)) > + > x(1)*sqrt(rho*k)*h*x(2)*x(1)*(g2-(1-h/2)*x(2)*x(1))*h*x(2)*(g2-(2-h)*x(2)*x(1))*pdf('Normal',sqrt(rho*k)*(h*x(2)*x(1)*(g2-(1-h/2)*x(2)*x(1))-z),0,1); > > h*x(2)*x(1)*(g2-(1-h/2)*x(2)*x(1) - z - > sqrt(rho*(1+k))*icdf('Normal',(1-1/(x(1)*x(2)))/h,0,1) + > (1+k)*sqrt(rho)*icdf('Normal',x(1)/w,0,1)]; Anna: Try using the following call to fsolve: x = fsolve( @myfun,x0 ); Note that you must also define {rho, k,...} and all of the other variables in your function. See the help file for fsolve and the section "Passing further parameters" for more information. Nicholas
|
Pages: 1 Prev: problem with parallel matlab Next: Interface C++ functions/Simulink |