How to add scientific units to a matrix?
Show older comments
h1 = sat_interpolated(:,2)*kJ/kg;
Is there a way to assign units to a vector or matrix?
Accepted Answer
More Answers (1)
Walter Roberson
on 12 Nov 2015
0 votes
You will need to create a new class of arithmetic values that has a display() method that formats the values the way you want. You might be able to subclass double() so that you do not need to work out all of the pure arithmetic functions (though it would certainly be more complicated than that if you wanted to be able to multiply or divide items with different units and have it automatically figure out what the appropriate units are.)
Typically it is much easier to just write a small display routine that formats the array the way you want, and then invoke the routine at need.
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!