1. ## Help with fsolve

I need some help with the following code.

%%%%%%%%%%%%%%%%%%

function [XY] = Test

V=[18.068;55.918];
K=[1005;213.2];
KAB=50;

phi1=[0.121];
phi2=1-phi1;

F = @(C) [-phi1+(C(1)/(1-K(1,1)*C(1))^2)*(1+((V(1,1)*KAB*C(2))/(V(2,1)*(1-K(2,1)*C(2)))));

-phi2+(C(2)/(1-K(2,1)*C(2))^2)*(1+((KAB*C(1))/(1-K(1,1)*C(1))))];

InitialGuess = [0.1;0.1];
Options = optimset('Display','iter');
XY = fsolve(F, InitialGuess, Options)

%%%%%%%%%%%%%%%%%%

When I use the phi1=[0.121] it's ok, but when I try to use
phi1=[0.121;0.214;0.341;0.423;0.512;0.611;0.721;0.834;92 5];

This code give an error. I need to solve this with more than one value for phi1 and I don't know how to do it.

Thanks in advance for any help.

2. Originally Posted by jucabala789
I need some help with the following code.

%%%%%%%%%%%%%%%%%%

function [XY] = Test

V=[18.068;55.918];
K=[1005;213.2];
KAB=50;

phi1=[0.121];
phi2=1-phi1;

F = @(C) [-phi1+(C(1)/(1-K(1,1)*C(1))^2)*(1+((V(1,1)*KAB*C(2))/(V(2,1)*(1-K(2,1)*C(2)))));

-phi2+(C(2)/(1-K(2,1)*C(2))^2)*(1+((KAB*C(1))/(1-K(1,1)*C(1))))];

InitialGuess = [0.1;0.1];
Options = optimset('Display','iter');
XY = fsolve(F, InitialGuess, Options)

%%%%%%%%%%%%%%%%%%

When I use the phi1=[0.121] it's ok, but when I try to use
phi1=[0.121;0.214;0.341;0.423;0.512;0.611;0.721;0.834;92 5];

This code give an error. I need to solve this with more than one value for phi1 and I don't know how to do it.

Thanks in advance for any help.
Loop over the values of phi1 putting the solutions into a results vector which is what you return

CB

3. Thanks for the help.