Thread Subject: Fsolve, CAT error : CAT arguments dimensions are not consistent

Subject: Fsolve, CAT error : CAT arguments dimensions are not consistent

From: Ali Modirkhazeni

Date: 13 Nov, 2009 15:45:27

Message: 1 of 2

Hi firends
I want to solve the set of non linear set of equitations as follow :
(I define them in Function Che1) :

function y = Che1(x)
R = 8.314;
T = 1000;
DF_CH4 = 19720;
DF_H2O = -192420;
DF_CO = -200240;
DF_CO2 = -395790;
RT = R*T;
y = [ DF_CH4/RT + log(x(1)/((x(1)+x(2)+x(3)+x(4)+x(5)))) + x(6)/RT +
4*x(8)/RT;
    DF_H2O/RT + log(x(5)/((x(1)+x(2)+x(3)+x(4)+x(5)))) + 2*x(8)/RT + x
(7)/RT;
    DF_CO/RT + log(x(3)/((x(1)+x(2)+x(3)+x(4)+x(5)))) + x(6)/RT + x(7)/
RT;
    DF_CO2/RT + log(x(4)/((x(1)+x(2)+x(3)+x(4)+x(5)))) + x(6)/RT + 2*x
(7)/RT;
    log(x(2)/((x(1)+x(2)+x(3)+x(4)+x(5)))) + x(6)/RT + 2*x(8)/RT;
    x(1) + x(3) + x(4) - 2;
    4*x(1) + 2*x(5) + 2*x(2) -14;
    x(5) + x(3) + 2*x(4) - 3;
    log(x(1)) + log(x(2)) + log(x(3)) + log(x(4)) + log(x(5)) +
3.1011] ;
end
But Matlab Makes an error The errors are as follow :

??? Error using ==> vertcat
CAT arguments dimensions are not consistent.

Error in ==> Che1 at 9
y = [ DF_CH4/RT + log(x(1)/((x(1)+x(2)+x(3)+x(4)+x(5)))) + x(6)/RT +
4*x(8)/RT;

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

Error in ==> solve_set at 4
y = fsolve(@Che1,x0,option);

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

Please Help Me
I really need to solve this set of nonlinear equations .

Thanks a lot

Subject: Fsolve, CAT error : CAT arguments dimensions are not consistent

From: Alan Weiss

Date: 16 Nov, 2009 20:46:22

Message: 2 of 2

I am not sure what is wrong here, but did you try to evaluate your
function Che1 at your x0 point? It seems to me that the error is not an
fsolve problem, it is a function definition problem.

Alan Weiss
MATLAB mathematical toolbox documentation

Ali Modirkhazeni wrote:
> Hi firends
> I want to solve the set of non linear set of equitations as follow :
> (I define them in Function Che1) :
>
> function y = Che1(x)
> R = 8.314;
> T = 1000;
> DF_CH4 = 19720;
> DF_H2O = -192420;
> DF_CO = -200240;
> DF_CO2 = -395790;
> RT = R*T;
> y = [ DF_CH4/RT + log(x(1)/((x(1)+x(2)+x(3)+x(4)+x(5)))) + x(6)/RT +
> 4*x(8)/RT;
> DF_H2O/RT + log(x(5)/((x(1)+x(2)+x(3)+x(4)+x(5)))) + 2*x(8)/RT + x
> (7)/RT;
> DF_CO/RT + log(x(3)/((x(1)+x(2)+x(3)+x(4)+x(5)))) + x(6)/RT + x(7)/
> RT;
> DF_CO2/RT + log(x(4)/((x(1)+x(2)+x(3)+x(4)+x(5)))) + x(6)/RT + 2*x
> (7)/RT;
> log(x(2)/((x(1)+x(2)+x(3)+x(4)+x(5)))) + x(6)/RT + 2*x(8)/RT;
> x(1) + x(3) + x(4) - 2;
> 4*x(1) + 2*x(5) + 2*x(2) -14;
> x(5) + x(3) + 2*x(4) - 3;
> log(x(1)) + log(x(2)) + log(x(3)) + log(x(4)) + log(x(5)) +
> 3.1011] ;
> end
> But Matlab Makes an error The errors are as follow :
>
> ??? Error using ==> vertcat
> CAT arguments dimensions are not consistent.
>
> Error in ==> Che1 at 9
> y = [ DF_CH4/RT + log(x(1)/((x(1)+x(2)+x(3)+x(4)+x(5)))) + x(6)/RT +
> 4*x(8)/RT;
>
> Error in ==> fsolve at 249
> fuser = funfcn{3}(x,varargin{:});
>
> Error in ==> solve_set at 4
> y = fsolve(@Che1,x0,option);
>
> Caused by:
> Failure in initial user-supplied objective function evaluation.
> FSOLVE cannot
> continue.
>
> Please Help Me
> I really need to solve this set of nonlinear equations .
>
> Thanks a lot

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com