MATLAB: How to add units to a number and differentiate between different inputs

units

Hi guys I am new to this community. I graduated civil engineering 2 weeks ago and I want to start and automating my work a bit. For that I wanted to learn Matlab. I bought couple of books with examples and tutorials that I can follow, however I have couple of questions that I can't find answer to. Lets say I have a variable – the depth of a beam is 300mm. How can I make Matlab recognise that the unit is "mm". I want to try a simple example such as 2m*300mm = "the answer in cm". I did the second moment of area (b*d^3)/12 so I want to assign b and d to me in mm how can i do this?
I have also learned the input function so I can write input=('Enter width: \n'), so that I can write the program so it asks me for breadth and then once again input=('Enter depth: \n'), and then i can write I=(b*d^3)/12 but I don't know how to assign that the first input is the b and the second input is d.
Pease help!

Best Answer

Units are now in MATLAB if you have Symbolic Math Toolbox. Try this, and see the tutorial: https://www.mathworks.com/help/symbolic/units-of-measurement-tutorial.html:
>> u = symunit;
>> x = 2*u.meter
x =
2*[m]
>> x = rewrite(x,u.ft)
x =
(2500/381)*[ft]
>> double(separateUnits(x))
ans =
6.5617