Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@plottools/islinespec.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 function varargout = islinespec(str) | |
2 % ISLINESPEC checks a string to the line spec syntax. | |
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
4 % | |
5 % DESCRIPTION: ISLINESPEC checks a string to the line spec syntax. | |
6 % | |
7 % CALL: ret = islinespec(str); | |
8 % [style_array ret] = islinespec(str); | |
9 % | |
10 % REMARK: The style_array is a cell array with the line style, marker style | |
11 % and the color style. | |
12 % style_array{1}: line style | |
13 % style_array{2}: marker style | |
14 % style_array{3}: color style | |
15 % | |
16 % VERSION: $Id: islinespec.m,v 1.1 2008/10/10 11:04:59 ingo Exp $ | |
17 % | |
18 % HISTORY: 21-08-2007 Diepholz | |
19 % Creation | |
20 % | |
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
22 | |
23 if nargin == 0 | |
24 str = ''; | |
25 elseif nargin == 1 | |
26 if ~ischar(str) | |
27 error('### The type of the input argument must be a ''char''.'); | |
28 end | |
29 else | |
30 error('### Unknown nuber of inputs.'); | |
31 end | |
32 | |
33 line_style = {'-.', '--', '-', ':'}; | |
34 full_name_marker_style = {'square', 'diamond', 'pentagram' , 'hexagram'}; | |
35 marker_style = {'+', 'o', 'O', '*', '.', 'x', '^', ... | |
36 '<', '>', 's', 'd', 'h', 'p', }; | |
37 full_name_color_style = {'red', 'green', 'cyan', 'yellow', ... | |
38 'white', 'blue', 'magenta', 'black'}; | |
39 color_style = {'r', 'g', 'c', 'y', 'w', 'b', 'm', 'k'}; | |
40 | |
41 out_line_style = ''; | |
42 out_marker_style = ''; | |
43 out_color_style = ''; | |
44 | |
45 copy_str = str; | |
46 found_marker_style = false; | |
47 found_color_style = false; | |
48 | |
49 %%%%%%%%%% Check the line_style %%%%%%%%%% | |
50 for ii = 1:length(line_style) | |
51 idx = strfind(copy_str, line_style{ii}); | |
52 if ~isempty(idx) | |
53 copy_str = strrep(copy_str, line_style{ii}, ''); | |
54 out_line_style = line_style{ii}; | |
55 break; | |
56 end | |
57 end | |
58 | |
59 %%%%%%%%%% Check full name marker style %%%%%%%%%% | |
60 for ii = 1:length(full_name_marker_style) | |
61 idx = strfind(copy_str, full_name_marker_style{ii}); | |
62 if ~isempty(idx) | |
63 copy_str = strrep(copy_str, full_name_marker_style{ii}, ''); | |
64 out_marker_style = full_name_marker_style{ii}; | |
65 found_marker_style = true; | |
66 break; | |
67 end | |
68 end | |
69 | |
70 %%%%%%%%%% Check full name color style %%%%%%%%%% | |
71 for ii = 1:length(full_name_color_style) | |
72 idx = strfind(copy_str, full_name_color_style{ii}); | |
73 if ~isempty(idx) | |
74 copy_str = strrep(copy_str, full_name_color_style{ii}, ''); | |
75 out_color_style = full_name_color_style{ii}; | |
76 found_color_style = true; | |
77 break; | |
78 end | |
79 end | |
80 | |
81 %%%%%%%%%% Check full marker style %%%%%%%%%% | |
82 if found_marker_style == false | |
83 for ii = 1:length(marker_style) | |
84 idx = strfind(copy_str, marker_style{ii}); | |
85 if ~isempty(idx) | |
86 copy_str = strrep(copy_str, marker_style{ii}, ''); | |
87 out_marker_style = marker_style{ii}; | |
88 break; | |
89 end | |
90 end | |
91 end | |
92 | |
93 %%%%%%%%%% Check full color style %%%%%%%%%% | |
94 if found_color_style == false | |
95 for ii = 1:length(color_style) | |
96 idx = strfind(copy_str, color_style{ii}); | |
97 if ~isempty(idx) | |
98 copy_str = strrep(copy_str, color_style{ii}, ''); | |
99 out_color_style = color_style{ii}; | |
100 break; | |
101 end | |
102 end | |
103 end | |
104 | |
105 %%%%%%%%%% Set the output %%%%%%%%%% | |
106 if isempty(copy_str) | |
107 ret = true; | |
108 else | |
109 ret = false; | |
110 end | |
111 | |
112 if nargout == 0 || nargout == 1 | |
113 varargout{1} = ret; | |
114 elseif nargout == 2 | |
115 varargout{1} = ret; | |
116 varargout{2} = {out_line_style, out_marker_style, out_color_style}; | |
117 else | |
118 error('### Unknown numbers of outputs.'); | |
119 end | |
120 | |
121 end |