Mercurial > hg > ltpda
comparison m-toolbox/html_help/help/ug/objects_working.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 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
2 "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> | |
3 | |
4 <html lang="en"> | |
5 <head> | |
6 <meta name="generator" content= | |
7 "HTML Tidy for Mac OS X (vers 1st December 2004), see www.w3.org"> | |
8 <meta http-equiv="Content-Type" content= | |
9 "text/html; charset=us-ascii"> | |
10 | |
11 <title>Working with LTPDA objects (LTPDA Toolbox)</title> | |
12 <link rel="stylesheet" href="docstyle.css" type="text/css"> | |
13 <meta name="generator" content="DocBook XSL Stylesheets V1.52.2"> | |
14 <meta name="description" content= | |
15 "Presents an overview of the features, system requirements, and starting the toolbox."> | |
16 </head> | |
17 | |
18 <body> | |
19 <a name="top_of_page" id="top_of_page"></a> | |
20 | |
21 <p style="font-size:1px;"> </p> | |
22 | |
23 <table class="nav" summary="Navigation aid" border="0" width= | |
24 "100%" cellpadding="0" cellspacing="0"> | |
25 <tr> | |
26 <td valign="baseline"><b>LTPDA Toolbox</b></td><td><a href="../helptoc.html">contents</a></td> | |
27 | |
28 <td valign="baseline" align="right"><a href= | |
29 "objects_create.html"><img src="b_prev.gif" border="0" align= | |
30 "bottom" alt="Creating LTPDA Objects"></a> <a href= | |
31 "ao_intro.html"><img src="b_next.gif" border="0" align= | |
32 "bottom" alt="Analysis Objects"></a></td> | |
33 </tr> | |
34 </table> | |
35 | |
36 <h1 class="title"><a name="f3-12899" id="f3-12899"></a>Working with LTPDA objects</h1> | |
37 <hr> | |
38 | |
39 <p> | |
40 <p> | |
41 The use of LTPDA objects requires some understanding of the nature of objects as implemented in MATLAB. | |
42 </p> | |
43 <p> | |
44 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>. | |
45 For convenience, the most important aspects in the context of LTPDA are reviewed below. | |
46 </p> | |
47 <p> | |
48 <ul> | |
49 <li> | |
50 <p><a href="objects_working.html#calling">Calling object methods</a></p> | |
51 </li> | |
52 <li> | |
53 <p><a href="objects_working.html#set">Setting object properties</a></p> | |
54 </li> | |
55 <li> | |
56 <p><a href="objects_working.html#copy">Copying objects</a></p> | |
57 </li> | |
58 <li><a href="objects_working.html#exploring">Exploring objects</a></li> | |
59 </ul> | |
60 </p> | |
61 | |
62 <a name="calling" id= "calling"><h3 class="title">Calling object methods</h3></a> | |
63 | |
64 <p> | |
65 Each class in LTPDA has a set of methods (functions) which can operate/act on instances of the class (objects). | |
66 For example, the AO class has a method <tt>psd</tt> which can compute the Power Spectral Density estimate of a | |
67 time-series AO. | |
68 </p> | |
69 <p> | |
70 To see which methods a particular class has, use the <tt>methods</tt> command. For example, | |
71 <div class="fragment"><pre> | |
72 >> methods(<span class="string">'ao'</span>) | |
73 </pre></div> | |
74 </p> | |
75 <p> | |
76 To call a method on an object, <tt>obj.method</tt>, or, <tt>method(obj)</tt>. For example, | |
77 <div class="fragment"><pre> | |
78 >> b = a.psd | |
79 </pre></div> | |
80 or | |
81 <div class="fragment"><pre> | |
82 >> b = psd(a) | |
83 </pre></div> | |
84 Additional arguments can be passed to the method (a <tt>plist</tt>, for example), as follows: | |
85 <div class="fragment"><pre> | |
86 >> b = a.psd(pl) | |
87 </pre></div> | |
88 or | |
89 <div class="fragment"><pre> | |
90 >> b = psd(a, pl) | |
91 </pre></div> | |
92 </p><br> | |
93 <p> | |
94 In order to pass multiple objects to a method, you must use the form | |
95 <div class="fragment"><pre> | |
96 >> b = psd(a1, a2, pl) | |
97 </pre></div> | |
98 </p><br> | |
99 <p> | |
100 Some methods can behave as modifiers which means that the object which the method acts on is modified. To | |
101 modify an object, just give no output. If we start with a time-series AO then modify it with the <tt>psd</tt> | |
102 method, | |
103 <div class="fragment"><pre> | |
104 >> a = ao(1:100, randn(100,1), 10) | |
105 >> a | |
106 M: running ao/display | |
107 ----------- ao 01: a ----------- | |
108 | |
109 name: None | |
110 data: (0,0.840375529753905) (0.1,-0.88803208232901) (0.2,0.100092833139322) (0.3,-0.544528929990548) (0.4,0.303520794649354) ... | |
111 -------- tsdata 01 ------------ | |
112 | |
113 fs: 10 | |
114 x: [100 1], double | |
115 y: [100 1], double | |
116 dx: [0 0], double | |
117 dy: [0 0], double | |
118 xunits: [s] | |
119 yunits: [] | |
120 nsecs: 10 | |
121 t0: 1970-01-01 00:00:01.000 | |
122 ------------------------------- | |
123 | |
124 hist: ao / ao / SId: fromVals ... -->$Id: ao .... S | |
125 mdlfile: empty | |
126 description: | |
127 UUID: 8cffab46-61f0-494a-af03-eb310aa76114 | |
128 -------------------------------- | |
129 </pre></div><br> | |
130 Then call the <tt>psd</tt> method: | |
131 <div class="fragment"><pre> | |
132 >> a.psd | |
133 M: running ao/psd | |
134 M: running ao/len | |
135 M: running ao/len | |
136 M: running ao/display | |
137 ----------- ao 01: PSD(a) ----------- | |
138 | |
139 name: PSD(a) | |
140 data: (0,0.117412356146407) (0.1,0.179893990497347) (0.2,0.173957816470448) (0.3,0.245076068355785) (0.4,0.213036543621994) ... | |
141 ----------- fsdata 01 ----------- | |
142 | |
143 fs: 10 | |
144 x: [51 1], double | |
145 y: [51 1], double | |
146 dx: [0 0], double | |
147 dy: [0 0], double | |
148 xunits: [Hz] | |
149 yunits: [Hz^(-1)] | |
150 t0: 1970-01-01 00:00:01.000 | |
151 navs: 1 | |
152 --------------------------------- | |
153 | |
154 hist: ao / psd / SId: psd.m,v 1.52 2009/09/05 05:57:32 mauro Exp S | |
155 mdlfile: empty | |
156 description: | |
157 UUID: 0d2395cd-22af-4645-a94c-69fa32c15982 | |
158 ------------------------------------- | |
159 </pre></div><br> | |
160 then the object <tt>a</tt> is converted to a frequency-series AO. | |
161 </p><br> | |
162 <p> | |
163 This modifier behaviour only works with certain methods, in particular, methods requiring more than one input object | |
164 will not behave as modifiers. | |
165 </p><br> | |
166 <a name="set" id= "set"><h3 class="title">Setting object properties</h3></a> | |
167 <p> | |
168 All object properties must be set using the appropriate setter method. For example, to set the name of a IIR filter | |
169 object, | |
170 <div class="fragment"><pre> | |
171 >> ii = miir(); | |
172 >> ii.setName(<span class="string">'My Filter'</span>); | |
173 </pre></div> | |
174 </p> | |
175 <p> | |
176 Reading the value of a property is achieved by: | |
177 <div class="fragment"><pre> | |
178 >> ii.name | |
179 | |
180 ans = | |
181 | |
182 My Filter | |
183 </pre></div> | |
184 </p><br> | |
185 | |
186 <a name="copy" id= "copy"><h3 class="title">Copying objects</h3></a> | |
187 <br> | |
188 <p> | |
189 Since all objects in LTPDA are handle objects, creating copies of objects needs to be done differently than in standard | |
190 MATLAB. For example, | |
191 <div class="fragment"><pre> | |
192 >> a = ao(); | |
193 >> b = a; | |
194 </pre></div> | |
195 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 | |
196 by the handle <tt>a</tt>. To see how this behaves, | |
197 <div class="fragment"><pre> | |
198 >> a = ao(); | |
199 >> b = a; | |
200 >> b.setName(<span class="string">'My Name'</span>); | |
201 >> a.name | |
202 | |
203 ans = | |
204 | |
205 My Name | |
206 </pre></div> | |
207 </p> | |
208 <p> | |
209 Copying the object can be achieved using the copy constructor: | |
210 <div class="fragment"><pre> | |
211 >> a = ao(); | |
212 >> b = ao(a); | |
213 >> b.setName(<span class="string">'My Name'</span>); | |
214 >> a.name | |
215 | |
216 ans = | |
217 | |
218 none | |
219 </pre></div> | |
220 <p>In this case, the variable <tt>b</tt> points to a new distinct copy of the object pointed to by <tt>a</tt>. | |
221 </p> | |
222 </p> | |
223 <p></p> | |
224 <h3 class="title"><a name="exploring" id="calling2">Exploring objects</a></h3> | |
225 <p> A browsing tool is provided on purpose to enable LTPDA objects exploring.</p> | |
226 <p><a href="gui_explorer.html">See the LTPDA Objects Explorer GUI documentation.</a></p> | |
227 | |
228 </p> | |
229 | |
230 <br> | |
231 <br> | |
232 <table class="nav" summary="Navigation aid" border="0" width= | |
233 "100%" cellpadding="0" cellspacing="0"> | |
234 <tr valign="top"> | |
235 <td align="left" width="20"><a href="objects_create.html"><img src= | |
236 "b_prev.gif" border="0" align="bottom" alt= | |
237 "Creating LTPDA Objects"></a> </td> | |
238 | |
239 <td align="left">Creating LTPDA Objects</td> | |
240 | |
241 <td> </td> | |
242 | |
243 <td align="right">Analysis Objects</td> | |
244 | |
245 <td align="right" width="20"><a href= | |
246 "ao_intro.html"><img src="b_next.gif" border="0" align= | |
247 "bottom" alt="Analysis Objects"></a></td> | |
248 </tr> | |
249 </table><br> | |
250 | |
251 <p class="copy">©LTP Team</p> | |
252 </body> | |
253 </html> |