Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
fsolve help!!!

Subject: fsolve help!!!

From: Adaora Okwo

Date: 25 Oct, 2010 18:41:38

Message: 1 of 2

Hello,
  I'm trying to solve the following system of nonlinear equations
using fsolve:

***
function F=acrefsolve2(x)
F=[692.4*x(1)^(-0.5)-917-x(3);
    135*x(2)^(-0.5)-230-x(3);
    7500-x(1)-x(2)];
***

but when I try to call the function using the following:

****
x0=[3500;4000;3];
x=fsolve(@acrefsolve2,x0)
***

I keep getting the following error message:

***
??? Error using ==> feval
Error: File: acrefsolve2.m Line: 12 Column: 1
Function definitions are not permitted in this
context.

Error in ==> fsolve at 254
            fuser = feval(funfcn{3},x,varargin{:});

Caused by:
    Failure in initial user-supplied objective
    function evaluation. FSOLVE cannot continue.
 ***

Does anyone know what the problem is? I'm new to MATLAB so I'm
unfamililar with much of the syntax. I've been using help files
online to get this far. Any help will be GREATLY appreciated. Thanks!

Subject: fsolve help!!!

From: Roger Stafford

Date: 25 Oct, 2010 19:09:04

Message: 2 of 2

Adaora Okwo <asokwo@gmail.com> wrote in message <c7e5baa4-82ff-4acc-a036-86d96413b1f2@30g2000yql.googlegroups.com>...
> Hello,
> I'm trying to solve the following system of nonlinear equations
> using fsolve:
>
> ***
> function F=acrefsolve2(x)
> F=[692.4*x(1)^(-0.5)-917-x(3);
> 135*x(2)^(-0.5)-230-x(3);
> 7500-x(1)-x(2)];
> ***
>
> but when I try to call the function using the following:
>
> ****
> x0=[3500;4000;3];
> x=fsolve(@acrefsolve2,x0)
> ***
>
> I keep getting the following error message:
>
> ***
> ??? Error using ==> feval
> Error: File: acrefsolve2.m Line: 12 Column: 1
> Function definitions are not permitted in this
> context.
>
> Error in ==> fsolve at 254
> fuser = feval(funfcn{3},x,varargin{:});
>
> Caused by:
> Failure in initial user-supplied objective
> function evaluation. FSOLVE cannot continue.
> ***
>
> Does anyone know what the problem is? I'm new to MATLAB so I'm
> unfamililar with much of the syntax. I've been using help files
> online to get this far. Any help will be GREATLY appreciated. Thanks!
- - - - - - - - - -
  You can convert your equations to a quartic polynomial equation in x(3). Using the 'roots' function on this, from each of its real roots (if any) you can determine the corresponding values of x(1) and x(2). There is no need to use 'fsolve' on this set of equations.

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us