recover_plot_options

PURPOSE ^

RECOVER_PLOT_OPTIONS - recover plot options

SYNOPSIS ^

function plotoptions=recover_plot_options(md,varargin,numberofplots);

DESCRIPTION ^

RECOVER_PLOT_OPTIONS - recover plot options

   Usage:
      plotoptions=recover_plot_options(md,varargin,numberofplots);

   See also: PARSE_OPTIONS, PLOTMODEL

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function plotoptions=recover_plot_options(md,varargin,numberofplots);
0002 %RECOVER_PLOT_OPTIONS - recover plot options
0003 %
0004 %   Usage:
0005 %      plotoptions=recover_plot_options(md,varargin,numberofplots);
0006 %
0007 %   See also: PARSE_OPTIONS, PLOTMODEL
0008 
0009 %initialize options string.
0010 plotoptions=cell(numberofplots,1);
0011 
0012 %initialize options.
0013 options=cell(0,2);
0014 
0015 for i=1:size(plotoptions,1),
0016     plotoptions{i}=options;
0017 end
0018 
0019 %make sure length(varargin) is even
0020 if mod(length(varargin),2),
0021     error('recover_plot_options error message: an even number of options is necessary');
0022 end
0023 
0024 %go through varargin, extract options and plug them into subplot options, by order of appearance
0025 for i=1:length(varargin)/2,
0026 
0027     optionstring=varargin{2*i-1};
0028     optionvalue=varargin{2*i};
0029 
0030     if length(optionstring)>4 & strcmpi(optionstring(end-3:end),'#all'),
0031         optionstring=optionstring(1:end-4);
0032         for j=1:size(plotoptions,1), 
0033             ispresent=0;
0034             options_j=plotoptions{j};
0035             for k=1:size(options_j,1),
0036                 if strcmpi(options_j{k,1},optionstring),
0037                     options_j{k,2}=optionvalue;
0038                     ispresent=1;
0039                 end
0040             end
0041             plotoptions{j}=options_j;
0042 
0043             if ~ispresent,
0044                 options_j{end+1,1}=optionstring;
0045                 options_j{end,2}=optionvalue;
0046                 plotoptions{j}=options_j;
0047             end
0048         end
0049     else
0050         
0051         %look for an a pound sign that would enforce choice of plot number
0052         if length(optionstring)>2 & strcmpi(optionstring(end-1),'#'),
0053             optionstring(end-1);
0054             plotnum=str2num(optionstring(end));
0055             options_j=plotoptions{plotnum};
0056             options_j{end+1,1}=optionstring(1:end-2);
0057             options_j{end,2}=optionvalue;
0058             plotoptions{plotnum}=options_j;
0059         else
0060             for j=1:numberofplots,
0061                 options_j=plotoptions{j};
0062 
0063                 alreadypresent=0;
0064                 for k=1:size(options_j,1),
0065                     if strcmpi(optionstring,options_j{k,1}),
0066                         alreadypresent=1;
0067                         break;
0068                     else
0069                         alreadypresent=0;
0070                     end
0071                 end
0072                 if alreadypresent,
0073                     continue;
0074                 else
0075                     options_j{end+1,1}=optionstring;
0076                     options_j{end,2}=optionvalue;
0077                     plotoptions{j}=options_j;
0078                     break;
0079                 end
0080             end
0081         end
0082     end
0083 end
0084 
0085 for i=1:length(plotoptions),
0086     options_i=plotoptions{i};
0087     new_options_i=cell(1,size(options_i,1)*size(options_i,2));
0088     counter=1;
0089     for j=1:size(options_i,1),
0090         new_options_i{counter}=options_i{j,1};
0091         new_options_i{counter+1}=options_i{j,2};
0092         counter=counter+2;
0093     end
0094     plotoptions{i}=new_options_i;
0095 end
0096 
0097 %%DEBUG
0098 %for i=1:length(plotoptions),
0099 %    disp(['Options ' num2str(i)]);
0100 %    plotoptions{i}
0101 %end
0102 %error('debug')

Generated on Sun 29-Mar-2009 20:22:55 by m2html © 2003