www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/UsingSpecializedObjectsExample.m
%% Using Specialized Objects % Compare the array |s| above to an object that you have designed % specifically to contain and manipulate time series data. For example, % the following statement creates a MATLAB(R) |timeseries| object. It is % initialized to store the same data as the structure |s| above: %% % Copyright 2015 The MathWorks, Inc. tsobj = timeseries(rand(10,1),.01:.01:.1,'Name','Data1'); %% % The function that creates the object |tsobj|, accepts sample data, sample % times, a property name/property value pair (|Name/Data1|), and uses a % default value of |Units| (which is |seconds|). % % The designer of this object created a special version of the |plot| % function that works directly with this object. For example: plot(tsobj) %% % Notice how the object's |plot| function creates a graph that is plotted % and labeled with the data from the |tsobj| object. As a user of this % object, you do not need write your own code to produce this graph. The % class design specifies the standard way to present graphs of |timeseries| % data and all clients of this object use the same code for plotting.