"Christian " <proechri@umich.edu> wrote in message
news:lhiofr$cgp$1@newscl01ah.mathworks.com...
> Hi all,
>
> I have a system of equations that I'd like to solve using fsolve. Suppose
> I have x equations and therefore insert x initial guesses. Sometimes I fix
> some (let's say y<x) of the variables ex ante and eliminate y equations
> from the system. I still would like to use fsolve with the same function
> file to solve for the remaining xy variables. Is there a way I can tell
> fsolve which equations to keep in the system and which variables to solve
> for, or do I have to write a new function file with only xy equations?
There's no option in FSOLVE to do this but you can do this in your objective
function using something like:
function y = myobjective(paramLoc, paramVal, fixedLoc, fixedVal);
x(paramLoc) = paramVal;
x(fixedLoc) = fixedVal;
x = reshape(x, [], 1); % It's often convenient to work with a column vector
% Now use x to compute y
You would use this as:
sol = fsolve(@(z) myobjective([1 3 5], z, [2 4], [pi, exp(1)]), [10; 11;
12])
For the example above, the x you would use to compute inside myobjective is:
[z(1);
pi;
z(2);
exp(1);
z(3)]

Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
