MATLAB Answers

Timeseries: how to set UserData using classes?

조회 수: 2(최근 30일)
Sebastian D'Amico
Sebastian D'Amico 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

Sebastian D'Amico
Sebastian D'Amico 13 Sep 2012
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,

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


Community Treasure Hunt

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

Start Hunting!

Translated by