File Exchange

image thumbnail

Molecular Weight Calculator Function

version 1.0.0.0 (3.37 KB) by Eckart Giebler
Function for calculating the molar weight of a substance given in form of a chemical formula

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

Comments and Ratings (5)

This is lovely!

Patroklus

MOHAMED

Thank you for the effort.

But what if the substance name was all in capital letters?
For example, CL instead of Cl.
I tried to change all small letters inside the m file but it didn't work.
Any help will be appretiated.
M. Selim

MATLAB Release Compatibility
Created with R12
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags