massFrac2molFrac: convert from mass to mole fraction
Version 1.0.0 (2.34 KB) by
Brandon Snow
Function converts a composition from mass fraction to mole fraction by solving a linear system of equations.
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 LinuxTags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
