
Object Oriented Design É 327
mean_min = mean([a.minutes]);
mean_hrs = mean([a.hours]);
out = Time(mean_hrs, mean_min, mean_sec);
When this function is invoked for the objects of class Time, the overloaded mean function
returns back the mean values in a new Time object “out”. It can be used in the command prompt
as follows:
>> d = [a b c]
>> e = mean(d)
The time is 14.666667hrs : 6.666667min :3.333333sec
Note that we had changed the display.m for handling the floating values as indicated in mean.m.
For further examples, we will stick to the integer format as before.
MATLAB allows you to even overload operators like +, –, *, etc. In example 11.10, of ...