Home > m > plottools > islinespec.m

islinespec

PURPOSE ^

ISLINESPEC checks a string to the line spec syntax.

SYNOPSIS ^

function varargout = islinespec(str)

DESCRIPTION ^

 ISLINESPEC checks a string to the line spec syntax.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: ISLINESPEC checks a string to the line spec syntax.

 CALL:        ret               = islinespec(str);
              [style_array ret] = islinespec(str);

 REMARK:      The style_array is a cell array with the line style, marker style
              and the color style.
              style_array{1}: line style
              style_array{2}: marker style
              style_array{3}: color style

 VERSION:     $Id: islinespec.m,v 1.3 2007/08/24 13:05:09 ingo Exp $

 HISTORY:     21-08-2007 Diepholz
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = islinespec(str)
0002 % ISLINESPEC checks a string to the line spec syntax.
0003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0004 %
0005 % DESCRIPTION: ISLINESPEC checks a string to the line spec syntax.
0006 %
0007 % CALL:        ret               = islinespec(str);
0008 %              [style_array ret] = islinespec(str);
0009 %
0010 % REMARK:      The style_array is a cell array with the line style, marker style
0011 %              and the color style.
0012 %              style_array{1}: line style
0013 %              style_array{2}: marker style
0014 %              style_array{3}: color style
0015 %
0016 % VERSION:     $Id: islinespec.m,v 1.3 2007/08/24 13:05:09 ingo Exp $
0017 %
0018 % HISTORY:     21-08-2007 Diepholz
0019 %                 Creation
0020 %
0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0022 
0023   if nargin == 0
0024     str = '';
0025   elseif nargin == 1
0026     if ~ischar(str)
0027       error('### The type of the input argument must be a ''char''.');
0028     end
0029   else
0030     error('### Unknown nuber of inputs.');
0031   end
0032 
0033   line_style             = {'-.', '--', '-', ':'};
0034   full_name_marker_style = {'square', 'diamond', 'pentagram' , 'hexagram'};
0035   marker_style =           {'+', 'o', 'O', '*', '.', 'x', '^', ...
0036                             '<', '>', 's', 'd', 'h', 'p', };
0037   full_name_color_style  = {'red',   'green', 'cyan',    'yellow', ...
0038                             'white', 'blue',  'magenta', 'black'};
0039   color_style            = {'r', 'g', 'c', 'y', 'w', 'b', 'm', 'k'};
0040 
0041   out_line_style   = '';
0042   out_marker_style = '';
0043   out_color_style  = '';
0044 
0045   copy_str           = str;
0046   found_marker_style = false;
0047   found_color_style  = false;
0048 
0049   %%%%%%%%%%   Check the line_style   %%%%%%%%%%
0050   for ii = 1:length(line_style)
0051     idx = strfind(copy_str, line_style{ii});
0052     if ~isempty(idx)
0053       copy_str = strrep(copy_str, line_style{ii}, '');
0054       out_line_style = line_style{ii};
0055       break;
0056     end
0057   end
0058 
0059   %%%%%%%%%%   Check full name marker style   %%%%%%%%%%
0060   for ii = 1:length(full_name_marker_style)
0061     idx = strfind(copy_str, full_name_marker_style{ii});
0062     if ~isempty(idx)
0063       copy_str = strrep(copy_str, full_name_marker_style{ii}, '');
0064       out_marker_style = full_name_marker_style{ii};
0065       found_marker_style = true;
0066       break;
0067     end
0068   end
0069 
0070   %%%%%%%%%%   Check full name color style   %%%%%%%%%%
0071   for ii = 1:length(full_name_color_style)
0072     idx = strfind(copy_str, full_name_color_style{ii});
0073     if ~isempty(idx)
0074       copy_str = strrep(copy_str, full_name_color_style{ii}, '');
0075       out_color_style = full_name_color_style{ii};
0076       found_color_style = true;
0077       break;
0078     end
0079   end
0080 
0081   %%%%%%%%%%   Check full marker style   %%%%%%%%%%
0082   if found_marker_style == false
0083     for ii = 1:length(marker_style)
0084       idx = strfind(copy_str, marker_style{ii});
0085       if ~isempty(idx)
0086         copy_str = strrep(copy_str, marker_style{ii}, '');
0087         out_marker_style = marker_style{ii};
0088         break;
0089       end
0090     end
0091   end
0092 
0093   %%%%%%%%%%   Check full color style   %%%%%%%%%%
0094   if found_color_style == false
0095     for ii = 1:length(color_style)
0096       idx = strfind(copy_str, color_style{ii});
0097       if ~isempty(idx)
0098         copy_str = strrep(copy_str, color_style{ii}, '');
0099         out_color_style = color_style{ii};
0100         break;
0101       end
0102     end
0103   end
0104 
0105   %%%%%%%%%%   Set the output   %%%%%%%%%%
0106   if isempty(copy_str)
0107     ret = true;
0108   else
0109     ret = false;
0110   end
0111 
0112   if nargout == 0 || nargout == 1
0113     varargout{1} = ret;
0114   elseif nargout == 2
0115     varargout{1} = ret;
0116     varargout{2} = {out_line_style, out_marker_style, out_color_style};
0117   else
0118     error('### Unknown numbers of outputs.');
0119   end
0120 
0121 end

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003