MATLAB Answers


Timeseries: how to set UserData using classes?

Asked by Sebastian D'Amico on 12 Sep 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) (this for standard units) or collection(1).Speed.otherUnits.kph.Data.
Any idea?
Thank you for reading guys.

  1 Comment

Hi again, I've made some improvement:
classdef tsGenerate < timeseries
function channel_obj = tsGenerate(dataVector,timeVector,name,nameStr,Channel)
channel_obj = channel_obj@timeseries(dataVector,timeVector,name,nameStr);
if nargin > 0 = Channel;
function dataPlot(channel_obj)
I can read the Standard Units using (my data is stored in Standard Units):
>> (meter per seconds)
and also different units using:
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:
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:
and if I want to plot my data in other units I would use:
>> speed.dataPlot.otherUnit.kph
Thanks guys,

Sign in to comment.

0 Answers