Info

This question is closed. Reopen it to edit or answer.

getting error in calculation and plot. what is the exact problem

1 view (last 30 days)
P=101.325;
a1=7.19736;b1=1574.99;c1=-34.29;
a2=7.07404;b2=1657.46;c2=-46.13;
x1=[0.0484 0.0539 0.0607 0.0696 0.0806 0.0911 0.1056 0.1197 0.1354 0.1436 0.1586 0.1815 0.2092 0.2202 0.2380 0.2648 0.2918 0.3166 0.3442 0.4015 0.4282 0.4644 0.5240 0.6091 0.6899 0.8213 ];
y1=[0.2704 0.3009 0.3213 0.3492 0.3866 0.4126 0.4492 0.4762 0.4885 0.5047 0.5323 0.5677 0.5969 0.6031 0.6237 0.6519 0.6681 0.6923 0.7197 0.7431 0.7443 0.7613 0.7860 0.8231 0.8633 0.9221 ];
T=[366.00 365.05 364.40 363.50 362.25 361.35 360.05 359.09 358.60 358.00 356.95 355.55 354.35 354.10 353.25 352.05 351.35 350.30 349.05 347.95 347.90 347.20 346.20 344.80 343.31 341.20 ];
Tsat1 = 338.1;
Tsat2 = 373.16;
x2=1-x1;
y2=1-y1;
p1= 10.^(a1 -( b1./(T+c1)));
p2= 10.^(a2 - (b2./(T+c2)));
gamma1_exp=(y1.*P)./(p1.*x1);
gamma2_exp=(y2.*P)./(p2.*x2);
gamma1_calc= @(c)(c1.*((c2.*x2)./(c1.*x1)+(c2.*x2)).^2);
gamma2_calc= @(c)(c2.*((c1.*x1)./(c1.*x1)+(c2.*x2)).^2);
ini_guess = [1,1];
U=@(c)(0.5*(sum(((gamma1_calc(c)-gamma1_exp)+(gamma2_calc(c)-gamma2_exp)).^2)));
display 'Vanlaar model activity coeffcients'
[c,fval] = fminsearch(U,ini_guess)
gamma1_calcvalue=@(c)exp(c(1).*(((c(2).*x2)./(c(1).*x1)+(c(2).*x2)).^2));
gamma2_calcvalue=@(c)exp(c(2).*(((c(1).*x1)./(c(1).*x1)+(c(2).*x2)).^2));
%---------Graphs----------%
subplot(3,3,1),
plot(x1,T,'*',y1,T,'-*'),
xlabel('x1(*),y1()'),
ylabel('T'),
title('Methanol-Water system'),
subplot(3,3,2),
plot(x1,gamma1_calcvalue,'*',x2,gamma2_calcvalue,'-*'),
xlabel('xi'),
ylabel('gammai'),
title('Van Laar model'),
subplot(3,3,6),
plot(x1,gamma1_exp,'*',x1,gamma1_calcvalue,'-*'),
xlabel('xi'),
ylabel('gamma_exp & gamma_calc'),
title('Van Laar model');

Answers (1)

KSSV
KSSV on 13 Feb 2020
YOu have a function handles in plot..you need to send input to those functions handles.
P=101.325;
a1=7.19736;b1=1574.99;c1=-34.29;
a2=7.07404;b2=1657.46;c2=-46.13;
x1=[0.0484 0.0539 0.0607 0.0696 0.0806 0.0911 0.1056 0.1197 0.1354 0.1436 0.1586 0.1815 0.2092 0.2202 0.2380 0.2648 0.2918 0.3166 0.3442 0.4015 0.4282 0.4644 0.5240 0.6091 0.6899 0.8213 ];
y1=[0.2704 0.3009 0.3213 0.3492 0.3866 0.4126 0.4492 0.4762 0.4885 0.5047 0.5323 0.5677 0.5969 0.6031 0.6237 0.6519 0.6681 0.6923 0.7197 0.7431 0.7443 0.7613 0.7860 0.8231 0.8633 0.9221 ];
T=[366.00 365.05 364.40 363.50 362.25 361.35 360.05 359.09 358.60 358.00 356.95 355.55 354.35 354.10 353.25 352.05 351.35 350.30 349.05 347.95 347.90 347.20 346.20 344.80 343.31 341.20 ];
Tsat1 = 338.1;
Tsat2 = 373.16;
x2=1-x1;
y2=1-y1;
p1= 10.^(a1 -( b1./(T+c1)));
p2= 10.^(a2 - (b2./(T+c2)));
gamma1_exp=(y1.*P)./(p1.*x1);
gamma2_exp=(y2.*P)./(p2.*x2);
gamma1_calc= @(c)(c1.*((c2.*x2)./(c1.*x1)+(c2.*x2)).^2);
gamma2_calc= @(c)(c2.*((c1.*x1)./(c1.*x1)+(c2.*x2)).^2);
ini_guess = [1,1];
U=@(c)(0.5*(sum(((gamma1_calc(c)-gamma1_exp)+(gamma2_calc(c)-gamma2_exp)).^2)));
display 'Vanlaar model activity coeffcients'
[c,fval] = fminsearch(U,ini_guess)
gamma1_calcvalue=@(c)exp(c(1).*(((c(2).*x2)./(c(1).*x1)+(c(2).*x2)).^2));
gamma2_calcvalue=@(c)exp(c(2).*(((c(1).*x1)./(c(1).*x1)+(c(2).*x2)).^2));
%---------Graphs----------%
subplot(3,3,1),
plot(x1,T,'*',y1,T,'-*'),
xlabel('x1(*),y1()'),
ylabel('T'),
title('Methanol-Water system'),
subplot(3,3,2),
plot(x1,gamma1_calcvalue(x1),'*',x2,gamma2_calcvalue(x2),'-*'),
xlabel('xi'),
ylabel('gammai'),
title('Van Laar model'),
subplot(3,3,6),
plot(x1,gamma1_exp,'*',x1,gamma1_calcvalue(x1),'-*'),
xlabel('xi'),
ylabel('gamma_exp & gamma_calc'),
title('Van Laar model');

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!