method gets or sets data for region name FORMAT res = region_name(o, r_nos) (get) OR FORMAT res = region_name(o, r_nos, [], default_prefix) (get) OR FORMAT res = region_name(o, r_nos, new_data) (set) Inputs o - marsy object r_nos - region number or array of region numbers or empty - giving all regions new_data - cell array, containing new names to set default_prefix - default prefix to make default name for regions with undefined names if empty, undefined region names are empty if not empty, undefined region names returned as prefix followed by region number defaults to 'region_', giving region names 'region_1', 'region_2' etc Returns (get call) res - cell array of region names OR (set call) res - object with new field names set $Id$
0001 function res = region_name(o, r_nos, new_data, default_prefix) 0002 % method gets or sets data for region name 0003 % FORMAT res = region_name(o, r_nos) (get) OR 0004 % FORMAT res = region_name(o, r_nos, [], default_prefix) (get) OR 0005 % FORMAT res = region_name(o, r_nos, new_data) (set) 0006 % 0007 % Inputs 0008 % o - marsy object 0009 % r_nos - region number 0010 % or array of region numbers 0011 % or empty - giving all regions 0012 % new_data - cell array, containing new names to set 0013 % default_prefix - default prefix to make default name for 0014 % regions with undefined names 0015 % if empty, undefined region names are empty 0016 % if not empty, undefined region names returned 0017 % as prefix followed by region number 0018 % defaults to 'region_', giving region names 0019 % 'region_1', 'region_2' etc 0020 % 0021 % Returns 0022 % (get call) 0023 % res - cell array of region names OR 0024 % (set call) 0025 % res - object with new field names set 0026 % 0027 % $Id$ 0028 0029 if nargin < 2 0030 r_nos = []; 0031 end 0032 if nargin < 3 0033 new_data = []; 0034 end 0035 if nargin < 4 0036 default_prefix = 'region_'; 0037 end 0038 0039 if ~isempty(new_data) % set call 0040 res = region(o, r_nos, new_data, 'name'); 0041 else % get call 0042 [rs r_nos] = region(o, r_nos); 0043 if isempty(rs), res = rs; return, end 0044 for i = 1:length(rs) 0045 if mars_struct('isthere', rs{i}, 'name') 0046 res{i} = rs{i}.name; 0047 elseif ~isempty(default_prefix) 0048 res{i} = sprintf('%s%d', default_prefix, r_nos(i)); 0049 else 0050 res{i} = ''; 0051 end 0052 end 0053 end 0054 0055 0056