view m-toolbox/classes/+utils/@prog/mup2mat.m @ 11:9174aadb93a5 database-connection-manager

Add LTPDA Repository utility functions into utils.repository
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% 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