Info
This question is closed. Reopen it to edit or answer.
Help with making a class
1 view (last 30 days)
Show older comments
Hello, im pretty new at matlab, and im trying to make a class.
In the class i need to register some temperatures (unknown how many). I need to count them, find the max temperature, and i need to add some more temperatures after finding these.
This is what it has come to this far, but not working (of cause, not finished at all)
But can anybody help me.
classdef Maalinger < handle properties Temperaturskema end methods function obj = Maalinger() end function registrer(obj, temperatur) obj.Temperaturskema = temperatur; end function count() obj.Temperaturskema = number(m); end function max(obj) obj.Temperaturskema = max(m); end function
end
end
0 Comments
Answers (1)
Simon
on 26 Aug 2013
Hi!
Your temperature property should be a vector. By adding temperature values with your "registrer" function you add the new value like in normal matlab syntax
obj.Temperaturskema = [obj.Temperaturskema; temperatur]
You get the count by saying
function count(obj)
fprintf('Number of temperature values: %d', length(obj.Temperaturskema))
end
Likewise for min/max:
function max(obj)
fprintf('Maximum temperature value: %f', max(obj.Temperaturskema))
end
HTH
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!