Molecular Weight Calculator Function
MolMass is a function for calculating the molar weight of a substance given in form of a chemical formula.
Function call: MM = MolMass(substance)
Substance is a string of the chemical formula of a substance.
Example: MM = MolMass('Fe2(SO4)3');
Substance can also be a vector of substances opened by '[' and divided by space, comma or semicolon.
Examples:
MM = MolMass('[Fe2(SO4)3 CuSO4 NaOH]') ---> MM = [399.88 159.61 39.997]
MM = MolMass('[H2SO4;H2O;P;Cl2]') ---> MM = [98.079 18.015 30.974 70.905]
MM = MolMass('[C3H5(OH)3,C3H7OH,C12H22O11,NaCl]') ---> MM = [92.095 60.096 342.3 58.442]
To distinguish charged substances the symbols '+' and '-' can be used.
Exampels:
MM = MolMass('Fe2+') ---> MM = 55.8470 - it means one mol of Fe2+
MM = MolMass('Fe3+') ---> MM = 55.8470 - it means one mol of Fe3+
but: MM = MolMass('Fe2') ---> MM = 111.694 - it means two moles of Fe
Cite As
Eckart Giebler (2026). Molecular Weight Calculator Function (https://in.mathworks.com/matlabcentral/fileexchange/26139-molecular-weight-calculator-function), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
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.0 |
