File Exchange

image thumbnail

fitAdsorptionIsothe​rm

version 1.1.0.0 (5.32 KB) by Steven Shimizu
Fits data to linear, Langmuir, Freundlich, Sips or Toth isotherms

7 Downloads

Updated 18 Jun 2014

View License

[xfit,yfit,isothermParams] = fitAdsorptionIsotherm(x,y,isotherm,ploton,xfit)

This function fits several adsorption isotherms to adsorption data (e.g.
moles adsorbed vs pressure). The function also optionally plots the data and fitted isotherm. The units of parameters are dependent on the
units provided by the x and y values.

For example, for the Langmuir isotherm, if x is in units of bar, and
y is in units of g/mL, then K has units of 1/bar, and N0 has units
of g/mL.

Inputs:
-x: The x-coordinate for the isotherm (e.g. pressure, relative
pressure, etc.)
-y: The y-coordinate for the isotherm (e.g. adsorbed moles, mass
adsorbed, etc.)
-isotherm: A string input indicating which isotherm to fit to the
data. Supported values for isotherm:
{'linear','langmuir','freundlich','sips','toth'}
-ploton: Optional flag to indicate whether the data and fitted
isotherm should be plotted (0 = no plot, 1 = plot).
-xfit: Optional input; The program calculates the value of the fitted
adsorption isotherm for each value of vector xfit fitted isotherm
adsorbed amount. If unspecified, the program returns yfit vector of
length 100 across the range min(x) and max(x).

Outputs:
-xfit: The values of x used to calculate the fitted isotherm values
(yfit)
-yfit: The calculated values of the fitted adsorption isotherm
corresponding to values of xfit
-isothermParams: A structure with named parameters corresponding to
the fitted parameters for the adsorption isotherm. P and N represent
the x and y-coordinates of the adsorption isotherm.
-'linear': N = K*P ----> {'K'}
-'langmuir': N = N0*K*P/(1+K*P) ----> {'K','N0'}
-'freundlich': N = K*P^(1/m) ----> {'K','m'}
-'sips': N = N0*K*P^(1/m)/(1+K*P^(1/m)) ----> {'K','N0','m'}
-'toth': N = N0*P/(1/K + P^t)^(1/t) ----> {'K','N0','t'}

For example, the parameters can be accessed like so:
>> K_fitted = isothermParams.K;
>> mfit = isothermParams.m;

Example Usage:
x =
[9.39,16.11,25.49,33.54,58.99,80.41,112.53,159.31,200.73,248.82,319.58];
y =
[8.84,15.91,22.98,30.94,48.63,61.03,78.74,96.50,109.84,122.32,137.50];

[xfit,yfit,isothermParams] = fitAdsorptionIsotherm(x,y,'langmuir',1);

Cite As

Steven Shimizu (2020). fitAdsorptionIsotherm (https://www.mathworks.com/matlabcentral/fileexchange/46981-fitadsorptionisotherm), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

Can we get a tutorial on how to use this code on matlab.

is there a tutorial about how to use this

Thanks a lot, very useful

Updates

1.1.0.0

Updated file description.

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux