diff m-toolbox/classes/+utils/@prog/mup2mat.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/+utils/@prog/mup2mat.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,30 @@
+% MUP2MAT converts Mupad string to MATLAB string
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: MUP2MAT converts:
+% MUP2MAT converts the Mupad string r containing
+% matrix, vector, or array to a valid MATLAB string.
+%
+% NOTE: Copied from the Symbolic Toolbox function sym/matlabFunction
+%
+% VERSION: $Id: mup2mat.m,v 1.1 2009/05/25 14:14:08 mauro Exp $
+%
+% HISTORY: 21-05-2009 M Hueller & L Ferraioli
+%             Creation
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function r = mup2mat(r)
+  
+  r = strtrim(char(r));
+  % Special case of the empty matrix or vector
+  if strcmp(r,'vector([])') || strcmp(r,'matrix([])') || ...
+      strcmp(r,'array([])')
+    r = '[]';
+  else
+    % Remove matrix, vector, or array from the string.
+    r = strrep(r,'matrix([[','['); r = strrep(r,'array([[','[');
+    r = strrep(r,'vector([','['); r = strrep(r,'],[',';');
+    r = strrep(r,']])',']'); r = strrep(r,'])',']');
+  end
+end