diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@pz/string.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,46 @@
+% STRING writes a command string that can be used to recreate the input pz object.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: STRING writes a command string that can be used to recreate
+%              the input pz object.
+%
+% CALL:        cmd = string(pz)
+%
+% VERSION:     $Id: string.m,v 1.10 2011/02/18 16:48:54 ingo Exp $
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function varargout = string(varargin)
+  
+  p = utils.helper.collect_objects(varargin(:), 'pz');
+  
+  cmd = '';
+  for j=1:numel(p)
+    
+    fstr = num2str(p(j).f, 20);
+    qstr = num2str(p(j).q, 20);
+    
+    % Create from 'f' and 'q'
+    pzstr = ['pz(' fstr ',' qstr ') '];
+    
+    test = eval(pzstr);
+    
+    % Check if the precision of 'f' and 'q' are high enough
+    if ~eq(test, p(j))
+      % Create from ri
+      pzstr = ['pz(plist(''ri'', ' mat2str(p(j).ri, 20) ')) '];
+    end
+    
+    cmd = [cmd pzstr];
+    
+  end
+  
+  %%% Wrap the command only with brackets if the there are more than one object
+  if numel(p) > 1
+    cmd = ['[' cmd(1:end-1) ']'];
+  end
+  
+  % set output
+  varargout{1} = cmd;
+end
+