Mercurial > hg > ltpda
comparison m-toolbox/classes/@pz/string.m @ 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 % STRING writes a command string that can be used to recreate the input pz object. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: STRING writes a command string that can be used to recreate | |
5 % the input pz object. | |
6 % | |
7 % CALL: cmd = string(pz) | |
8 % | |
9 % VERSION: $Id: string.m,v 1.10 2011/02/18 16:48:54 ingo Exp $ | |
10 % | |
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
12 | |
13 function varargout = string(varargin) | |
14 | |
15 p = utils.helper.collect_objects(varargin(:), 'pz'); | |
16 | |
17 cmd = ''; | |
18 for j=1:numel(p) | |
19 | |
20 fstr = num2str(p(j).f, 20); | |
21 qstr = num2str(p(j).q, 20); | |
22 | |
23 % Create from 'f' and 'q' | |
24 pzstr = ['pz(' fstr ',' qstr ') ']; | |
25 | |
26 test = eval(pzstr); | |
27 | |
28 % Check if the precision of 'f' and 'q' are high enough | |
29 if ~eq(test, p(j)) | |
30 % Create from ri | |
31 pzstr = ['pz(plist(''ri'', ' mat2str(p(j).ri, 20) ')) ']; | |
32 end | |
33 | |
34 cmd = [cmd pzstr]; | |
35 | |
36 end | |
37 | |
38 %%% Wrap the command only with brackets if the there are more than one object | |
39 if numel(p) > 1 | |
40 cmd = ['[' cmd(1:end-1) ']']; | |
41 end | |
42 | |
43 % set output | |
44 varargout{1} = cmd; | |
45 end | |
46 |