Timeseries: how to set UserData using classes?

조회 수: 2 (최근 30일)
Sebastian D'Amico
Sebastian D'Amico 2012년 9월 12일
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
Sebastian D'Amico
Sebastian D'Amico 2012년 9월 13일
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,

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Argument Definitions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by