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
Eckart Giebler (2019). Molecular Weight Calculator Function (https://www.mathworks.com/matlabcentral/fileexchange/26139-molecular-weight-calculator-function), MATLAB Central File Exchange. Retrieved .
Create scripts with code, output, and formatted text in a single executable document.
Sandra Correa (view profile)
Benjamin Lewis (view profile)
This is lovely!
Patroklus (view profile)
MOHAMED (view profile)
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
Adam kubacki (view profile)