view m-toolbox/classes/@msym/msym.m @ 1:2014ba5b353a database-connection-manager

Remove old code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Sat, 03 Dec 2011 18:13:55 +0100
parents f0afece42f48
children
line wrap: on
line source

classdef (Hidden = true) msym
  
  properties
    s = '';
  end
  
  
  methods
    
    function ms = msym(varargin)
      
      if isstruct(varargin{1})
        ms.s = varargin{1}.s;
      else
        
        if ischar(varargin{1})
          ms.s = varargin{1};
        elseif isnumeric(varargin{1})
          ms.s = mat2str(varargin{1});
        elseif isa(varargin{1}, 'msym')
          ms.s = varargin{1}.s;
        else
          error('### Unknown class [%s] to convert it to a symbolic class.', class(varargin{1}));
        end
      end
      
    end
    
    function display(varargin)
      disp(varargin{1}.s);
    end
    
    function s = char(o)
      s = o.s;
    end
    
    function result = eq(obj1, obj2, varargin)
      result = 1;
      if numel(obj1) ~= numel(obj2)
        utils.helper.msg(utils.const.msg.PROC1, 'NOT EQUAL: The size of the %s-object''s. [%d] <-> [%d]', class(obj1), numel(obj1), numel(obj2));
        result = 0;
        return
      end
      if ~strcmp(obj1.s, obj2.s)
        utils.helper.msg(utils.const.msg.PROC1, 'NOT EQUAL: %s.%s', class(obj1), 's');
        result = 0;
        return
      end
    end
    
    function o = subs(o, params, vals)
      if ischar(params)
        params = {params};
      end
      if isnumeric(vals)
        vals = {vals};
      end
      if numel(vals) ~= numel(params)
        error('### Please specify one value per parameter');
      end
      for kk=1:numel(params)
        o.s = regexprep(o.s, ['\<' params{kk} '\>'], mat2str(vals{kk}));
      end
    end
    
    function a = double(o)
      try
        a = eval(o.s);
      catch Me
        disp(Me.message);
        error('### Evaluation of the symbolic expression failed. Perhaps it contains undefined parameters');
      end
    end
    
    
    
  end
  
  methods (Static = true)
    function obj = initObjectWithSize(n,m)
      obj = msym.newarray([n m]);
    end
  end
  
  methods (Static = true, Hidden = true)
    varargout = loadobj(varargin)
  end
    
end