Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Help with making a class
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Simon
el 26 de Ag. de 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 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!