Mercurial > hg > ltpda
comparison m-toolbox/html_help/help/ug/objects_working_content.html @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 <p> | |
2 The use of LTPDA objects requires some understanding of the nature of objects as implemented in MATLAB. | |
3 </p> | |
4 <p> | |
5 For full details of objects in MATLAB, refer to <a href="matlab:web(['jar:file:///' matlabroot '/help/techdoc/help.jar!/matlab_oop/ug_intropage.html'])">MATLAB Classes and Object-Oriented Programming</a>. | |
6 For convenience, the most important aspects in the context of LTPDA are reviewed below. | |
7 </p> | |
8 <p> | |
9 <ul> | |
10 <li> | |
11 <p><a href="objects_working.html#calling">Calling object methods</a></p> | |
12 </li> | |
13 <li> | |
14 <p><a href="objects_working.html#set">Setting object properties</a></p> | |
15 </li> | |
16 <li> | |
17 <p><a href="objects_working.html#copy">Copying objects</a></p> | |
18 </li> | |
19 <li><a href="objects_working.html#exploring">Exploring objects</a></li> | |
20 </ul> | |
21 </p> | |
22 | |
23 <a name="calling" id= "calling"><h3 class="title">Calling object methods</h3></a> | |
24 | |
25 <p> | |
26 Each class in LTPDA has a set of methods (functions) which can operate/act on instances of the class (objects). | |
27 For example, the AO class has a method <tt>psd</tt> which can compute the Power Spectral Density estimate of a | |
28 time-series AO. | |
29 </p> | |
30 <p> | |
31 To see which methods a particular class has, use the <tt>methods</tt> command. For example, | |
32 <div class="fragment"><pre> | |
33 >> methods(<span class="string">'ao'</span>) | |
34 </pre></div> | |
35 </p> | |
36 <p> | |
37 To call a method on an object, <tt>obj.method</tt>, or, <tt>method(obj)</tt>. For example, | |
38 <div class="fragment"><pre> | |
39 >> b = a.psd | |
40 </pre></div> | |
41 or | |
42 <div class="fragment"><pre> | |
43 >> b = psd(a) | |
44 </pre></div> | |
45 Additional arguments can be passed to the method (a <tt>plist</tt>, for example), as follows: | |
46 <div class="fragment"><pre> | |
47 >> b = a.psd(pl) | |
48 </pre></div> | |
49 or | |
50 <div class="fragment"><pre> | |
51 >> b = psd(a, pl) | |
52 </pre></div> | |
53 </p><br> | |
54 <p> | |
55 In order to pass multiple objects to a method, you must use the form | |
56 <div class="fragment"><pre> | |
57 >> b = psd(a1, a2, pl) | |
58 </pre></div> | |
59 </p><br> | |
60 <p> | |
61 Some methods can behave as modifiers which means that the object which the method acts on is modified. To | |
62 modify an object, just give no output. If we start with a time-series AO then modify it with the <tt>psd</tt> | |
63 method, | |
64 <div class="fragment"><pre> | |
65 >> a = ao(1:100, randn(100,1), 10) | |
66 >> a | |
67 M: running ao/display | |
68 ----------- ao 01: a ----------- | |
69 | |
70 name: None | |
71 data: (0,0.840375529753905) (0.1,-0.88803208232901) (0.2,0.100092833139322) (0.3,-0.544528929990548) (0.4,0.303520794649354) ... | |
72 -------- tsdata 01 ------------ | |
73 | |
74 fs: 10 | |
75 x: [100 1], double | |
76 y: [100 1], double | |
77 dx: [0 0], double | |
78 dy: [0 0], double | |
79 xunits: [s] | |
80 yunits: [] | |
81 nsecs: 10 | |
82 t0: 1970-01-01 00:00:01.000 | |
83 ------------------------------- | |
84 | |
85 hist: ao / ao / SId: fromVals ... -->$Id: ao .... S | |
86 mdlfile: empty | |
87 description: | |
88 UUID: 8cffab46-61f0-494a-af03-eb310aa76114 | |
89 -------------------------------- | |
90 </pre></div><br> | |
91 Then call the <tt>psd</tt> method: | |
92 <div class="fragment"><pre> | |
93 >> a.psd | |
94 M: running ao/psd | |
95 M: running ao/len | |
96 M: running ao/len | |
97 M: running ao/display | |
98 ----------- ao 01: PSD(a) ----------- | |
99 | |
100 name: PSD(a) | |
101 data: (0,0.117412356146407) (0.1,0.179893990497347) (0.2,0.173957816470448) (0.3,0.245076068355785) (0.4,0.213036543621994) ... | |
102 ----------- fsdata 01 ----------- | |
103 | |
104 fs: 10 | |
105 x: [51 1], double | |
106 y: [51 1], double | |
107 dx: [0 0], double | |
108 dy: [0 0], double | |
109 xunits: [Hz] | |
110 yunits: [Hz^(-1)] | |
111 t0: 1970-01-01 00:00:01.000 | |
112 navs: 1 | |
113 --------------------------------- | |
114 | |
115 hist: ao / psd / SId: psd.m,v 1.52 2009/09/05 05:57:32 mauro Exp S | |
116 mdlfile: empty | |
117 description: | |
118 UUID: 0d2395cd-22af-4645-a94c-69fa32c15982 | |
119 ------------------------------------- | |
120 </pre></div><br> | |
121 then the object <tt>a</tt> is converted to a frequency-series AO. | |
122 </p><br> | |
123 <p> | |
124 This modifier behaviour only works with certain methods, in particular, methods requiring more than one input object | |
125 will not behave as modifiers. | |
126 </p><br> | |
127 <a name="set" id= "set"><h3 class="title">Setting object properties</h3></a> | |
128 <p> | |
129 All object properties must be set using the appropriate setter method. For example, to set the name of a IIR filter | |
130 object, | |
131 <div class="fragment"><pre> | |
132 >> ii = miir(); | |
133 >> ii.setName(<span class="string">'My Filter'</span>); | |
134 </pre></div> | |
135 </p> | |
136 <p> | |
137 Reading the value of a property is achieved by: | |
138 <div class="fragment"><pre> | |
139 >> ii.name | |
140 | |
141 ans = | |
142 | |
143 My Filter | |
144 </pre></div> | |
145 </p><br> | |
146 | |
147 <a name="copy" id= "copy"><h3 class="title">Copying objects</h3></a> | |
148 <br> | |
149 <p> | |
150 Since all objects in LTPDA are handle objects, creating copies of objects needs to be done differently than in standard | |
151 MATLAB. For example, | |
152 <div class="fragment"><pre> | |
153 >> a = ao(); | |
154 >> b = a; | |
155 </pre></div> | |
156 in this case, the variable <tt>b</tt> is a copy of the handle <tt>a</tt>, not a copy of the object pointed too | |
157 by the handle <tt>a</tt>. To see how this behaves, | |
158 <div class="fragment"><pre> | |
159 >> a = ao(); | |
160 >> b = a; | |
161 >> b.setName(<span class="string">'My Name'</span>); | |
162 >> a.name | |
163 | |
164 ans = | |
165 | |
166 My Name | |
167 </pre></div> | |
168 </p> | |
169 <p> | |
170 Copying the object can be achieved using the copy constructor: | |
171 <div class="fragment"><pre> | |
172 >> a = ao(); | |
173 >> b = ao(a); | |
174 >> b.setName(<span class="string">'My Name'</span>); | |
175 >> a.name | |
176 | |
177 ans = | |
178 | |
179 none | |
180 </pre></div> | |
181 <p>In this case, the variable <tt>b</tt> points to a new distinct copy of the object pointed to by <tt>a</tt>. | |
182 </p> | |
183 </p> | |
184 <p></p> | |
185 <h3 class="title"><a name="exploring" id="calling2">Exploring objects</a></h3> | |
186 <p> A browsing tool is provided on purpose to enable LTPDA objects exploring.</p> | |
187 <p><a href="gui_explorer.html">See the LTPDA Objects Explorer GUI documentation.</a></p> |