Timeseries: how to set UserData using classes?

1 visualización (últimos 30 días)
Sebastian D'Amico
Sebastian D'Amico el 12 de Sept. de 2012
Hi to all, I'm learning Object-Oriented Programming with MATLAB and I have a question for you guys. I have some timeseries and I want to store them into a collection. The problem is that I would add some properties to each timeserie and I figured out that UserData field into timeserie could be used for this purpose. But how to call a class that set new properties? In particular I would add some unit of measure information and also the possibility to compute the data in a different unit of measure, for example: collection(1).Speed.StandardUnits.ms.Data (this for standard units) or collection(1).Speed.otherUnits.kph.Data.
Any idea?
Thank you for reading guys.
  1 comentario
Sebastian D'Amico
Sebastian D'Amico el 13 de Sept. de 2012
Hi again, I've made some improvement:
classdef tsGenerate < timeseries
properties
channel
end
methods
function channel_obj = tsGenerate(dataVector,timeVector,name,nameStr,Channel)
channel_obj = channel_obj@timeseries(dataVector,timeVector,name,nameStr);
if nargin > 0
channel_obj.channel = Channel;
end
end
function dataPlot(channel_obj)
plot(channel_obj.Data)
end
end
end
I can read the Standard Units using (my data is stored in Standard Units):
>>speed.channel.Quantity.SIunit.ms (meter per seconds)
and also different units using:
>> speed.channel.Quantity.otherUnits.kph
Now what I need is to create a method that plot my data stored into:
>> speed.Data
but I also want to have the possibility to plot my data using otherUnits.
I have a class called otherUnits that store also the conversion constant to convert data from meter per seconds to kph. So it's available from:
>> speed.channel.Quantity.otherUnits.kph.conversionConstant
How to create a method with sort of "submethods" to plot my data using differents units?
For example, if I want to plot my data in standard units I would use:
>> speed.dataPlot.SIunit.ms
and if I want to plot my data in other units I would use:
>> speed.dataPlot.otherUnit.kph
Thanks guys,

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Octave en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by