Hi
I have 15 equations and 15 unknowns. Eq 1 to 11 has Ln which makes it
a nonlinear. Eq 1215 is linear. Unknowns are x(1), x(2), x(3)......
x(15).
after testing the code in the command window, I got this error:
==============
>> x0 = [5;5;5;5;5;5;5;5;5;5;5;5;5;5;5]; % Make a starting guess at the solution
options=optimset('Display','iter'); % Option to display output
[x,fval] = fsolve(@f2,x0,options) % Call solver
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> f2 at 18
Y(12)=[3 0 2 2 3 3 1 0 1 1 1]*x(1:11)'0.041121;
Error in ==> fsolve at 254
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial usersupplied objective function evaluation.
FSOLVE cannot
continue.
==============
I have spent countless hours trying to fix the errors but I just
cannot get it.
Here is the mfile code:
==============
function Y=f2(x)
G1=340.02;G2=219.98;G3=78.04767;G4=9.674889;G5=94.05569;G6=40.71902;
G7=32.28801;G8=2.892587;G9=399.21;G10=164.6;G11=626.986;
R=8.315;T=573;
summation=sum(x(1:11)); % equation #15
RT=1/(R*T); % Less Computation~Less Error
Y(1)=RT*(G1+(1/RT)*log(x(1)/summation)+3*x(12)+8*x(13)+3*x(14));
Y(2)=RT*(G2+(1/RT)*log(x(2)/summation)+2*x(13)+x(14));
Y(3)=RT*(G3+(1/RT)*log(x(3)/summation)+2*x(12)+4*x(13));
Y(4)=RT*(G4+(1/RT)*log(x(4)/summation)+2*x(12)+6*x(13));
Y(5)=RT*(G5+(1/RT)*log(x(5)/summation)+3*x(12)+6*x(13));
Y(6)=RT*(G6+(1/RT)*log(x(6)/summation)+3*x(12)+8*x(13));
Y(7)=RT*(G7+(1/RT)*log(x(7)/summation)+x(12)+4*x(13));
Y(8)=log(x(8)/summation)+2*x(13)*RT;
Y(9)=RT*(G9+(1/RT)*log(x(10)/summation)+x(12)+x(14));
Y(10)=RT*(G10+(1/RT)*log(x(9)/summation)+x(12)+2*x(14));
Y(11)=RT*(G11+(1/RT)*log(x(11)/summation)+x(12));
Y(12)=[3 0 2 2 3 3 1 0 1 1 1]*x(1:11)'0.041121;
Y(13)=[8 2 4 6 6 8 4 2]*x(1:8)'0.436582;
Y(14)=[3 1 0 0 0 0 0 0 1 2]*x(1:10)'0.204584;
%Y(15)=summation;
==============
Any help is very much appreciated.
Thanks.
