Molecular Weight Calculator Function

Function for calculating the molar weight of a substance given in form of a chemical formula
1.3K Downloads
Updated 18 Dec 2009

View License

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 (2025). Molecular Weight Calculator Function (https://www.mathworks.com/matlabcentral/fileexchange/26139-molecular-weight-calculator-function), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R12
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Chemistry in Help Center and MATLAB Answers
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0.0