Naisarg
Naisarg

Reputation: 21

Matlab solve function is not giving a unique solution

I am trying to convert a Maple code in Matlab. The maple code is:

KH1:= 5.5531*10^(-13):
KH2:= 8.1493*10^(-11):
KP:= 10^(-2):
P1:= array(1..35):
P2:= array(1..35):
T1:= array(1..35):
T2:= array(1..35):
H1:= array(1..35):
H2:= array(1..35):
P1[1]:= 10^(-6):
P2[1]:= 10^(-6):
T1[1]:= 10^(-11):
T2[1]:= 10^(-11):
for i from 1 to 35 by 1 do
    e1:= (e*KH1)-(a*c):
    e2:= (f*KH2)-(b*d):
    e3:= P1[i]-(a+e+h):
    e4:= P2[i]-(b+f+h):
    e5:= T1[i]-(c+e):
    e6:= T2[i]-(d+f):
    e8:= (h*KP)-(a*b):
    soln:=solve({e1,e2,e3,e4,e5,e6,e8,a>=0,b>=0,c>=0,d>=0,e>=0,f>=0,h>=0},{a,b,c,d,e,f,h}):

When i code it in Matlab, using the solve function:

% Constants
KH1 = 5.5531e-13;
KH2 = 8.1493e-11;
KD = 1e-2;

% Arrays
P1 = zeros(1, 35);
P2 = zeros(1, 35);
T1 = zeros(1, 35);
T2 = zeros(1, 35);
H1 = zeros(1, 35);
H2 = zeros(1, 35);

% Initial values
P1(1) = 1e-6;
P2(1) = 1e-6;
T1(1) = 1e-10;
T2(1) = 1e-10;

% Loop through 1 to 35
for i = 1:5
    syms a b c d e f h
    e1 = (e * KH1) - (a * c);
    e2 = (f * KH2) - (b * d);
    e3 = P1(i) - (a + e + h);
    e4 = P2(i) - (b + f + h);
    e5 = T1(i) - (c + e);
    e6 = T2(i) - (d + f);
    e8 = (h * KD) - (a * b);
   
    [sola,solb,solc,sold,sole,solf,solh, param, cond] = solve([e1, e2, e3, e4, e5, e6, e8, a > 0, b > 0, c > 0, d > 0, e > 0, f > 0, h > 0],"Real",true, ReturnConditions=true)

The output is not unique solution, i tried 'vpa' to get a answer but that is different from the answer of Maple code.

Upvotes: 0

Views: 32

Answers (0)

Related Questions