massFrac2molFrac: convert from mass to mole fraction

Function converts a composition from mass fraction to mole fraction by solving a linear system of equations.
46 Downloads
Updated 25 Mar 2022

View License

A simple function to easily convert compositions from mass fraction to mole fraction.
Inputs:
w = a vector containing the composition in mass fraction. Must sum to 1
elem = cell array of elements in the same order as they are listed in w
Ouput:
x = composition vector in mole fraction
Example
w = [0.01, 0.1, 0.89];
elem = {'C','Cu','Fe'};
x = massFrac2molFrac(w,elem)
The output is
x =
0.0454
0.0858
0.8688

Cite As

Brandon Snow (2026). massFrac2molFrac: convert from mass to mole fraction (https://www.mathworks.com/matlabcentral/fileexchange/108734-massfrac2molfrac-convert-from-mass-to-mole-fraction), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2020b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Version Published Release Notes
1.0.0