Results 1 to 3 of 3

Math Help - Help with fsolve

  1. #1
    Newbie
    Joined
    Nov 2009
    Posts
    5

    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.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by jucabala789 View Post
    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
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Nov 2009
    Posts
    5
    Thanks for the help.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. [MATLAP] no fsolve
    Posted in the Math Software Forum
    Replies: 2
    Last Post: May 23rd 2010, 01:30 AM
  2. Matlab - fsolve
    Posted in the Math Software Forum
    Replies: 0
    Last Post: April 18th 2010, 12:19 PM
  3. Need help with fsolve in Matlab M file
    Posted in the Math Software Forum
    Replies: 0
    Last Post: June 6th 2009, 03:06 PM

Search Tags


/mathhelpforum @mathhelpforum