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)];
|
|
0
|
|
|
|
Reply
|
Anna
|
5/19/2010 2:40:22 PM |
|
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
|
|
0
|
|
|
|
Reply
|
Nicholas
|
5/19/2010 4:08:36 PM
|
|
|
1 Replies
212 Views
(page loaded in 0.025 seconds)
Similiar Articles: Problem with using fsolve to solve nonlinear equations - comp.soft ...Hello everybody, I'm trying to solve a set of nonlinear equations using fsolve. But I have a problem. My script looks similar to this: ..... ..... Solver stopped prematurely - comp.soft-sys.matlabHi all! I have a problem on the fsolve comand, I have 7 unknowns in 7 equations and when i launch my function with the fsolve it appears that error: ... fsolve help!!! - comp.soft-sys.matlabfsolve - Solve system of nonlinear equations fsolve -Solve system of nonlinear equations Equation. Solves a problem specified by. F(x) = 0. for x, where x is a vector and ... solving the system of non linear equation - comp.soft-sys.matlab ...Sir i have problem in solving the system of non linear equation with 3 or 4 equation. ... how to use fsolve - comp.soft-sys.matlab fsolve help!!! - comp.soft-sys.matlab Hello ... estimation parameter using fminsearch - comp.soft-sys.matlab ...Thanks Yi.... >BTW, you may find 'fsolve' is more appropriate for your problem. Would you mean 'fsolve' in maple?..I have no idea, could you please explain a little ... Jacobians for Gauss-Newton - comp.soft-sys.matlabIf you're talking about the fsolve() command in the optimization toolbox ... written function which computes the Jacobian for your particular problem. See "help fsolve ... closed loop in simulink - comp.soft-sys.matlabHi everyone, I am trying to model a closed loop system within the Simulink with Embedded Matlab functions (contains ODE's and fsolve functions). I have a problem with ... how to use fsolve - comp.soft-sys.matlabfsolve - Solve system of nonlinear equations fsolve -Solve system of nonlinear equations Equation. Solves a problem specified by. F(x) = 0. for x, where x is a vector and ... solving large number of nonlinear equations using matlab - comp ...So you might do better to look for a numerical solution using fsolve. Each ... problem with 'decic' function for set of implicit ODE's - comp ... solving large ... Plot problems - comp.soft-sys.matlabPlotting problem - comp.soft-sys.matlab nullcline plot - fsolve problem? - comp.soft-sys.matlab Hey guys, I am solving a set of ODE's and am currently having problems with ... fsolve - Solve system of nonlinear equationsfsolve -Solve system of nonlinear equations Equation. Solves a problem specified by. F(x) = 0. for x, where x is a vector and F(x) is a function that returns a vector ... fsolve :: Functions (Optimization Toolbox)Solve system of nonlinear equations. Equation. Solves a problem specified by. for x, where x is a vector and F(x) is a function that returns a vector value. 7/15/2012 10:18:47 PM
|