method gets or sets data for region field FORMAT res = region_field(fieldname, o, r_nos) (get) OR FORMAT res = region_field(fieldname, o, r_nos, new_data) (set) Inputs fieldname - name of field to get / set o - marsy object r_nos - region number or array of region numbers or empty - giving all regions new_data - cell array, containing new data to set Returns (get call) res - cell array of region field values OR (set call) res - object with new field data set $Id$
0001 function res = region_field(fieldname, o, r_nos, new_data) 0002 % method gets or sets data for region field 0003 % FORMAT res = region_field(fieldname, o, r_nos) (get) OR 0004 % FORMAT res = region_field(fieldname, o, r_nos, new_data) (set) 0005 % 0006 % Inputs 0007 % fieldname - name of field to get / set 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 data to set 0013 % 0014 % Returns 0015 % (get call) 0016 % res - cell array of region field values OR 0017 % (set call) 0018 % res - object with new field data set 0019 % 0020 % $Id$ 0021 0022 if nargin < 2 0023 error('Need fieldname'); 0024 end 0025 if nargin < 3 0026 r_nos = []; 0027 end 0028 if nargin < 4 % get call 0029 [rs r_nos] = region(o, r_nos); 0030 for i = 1:length(r_nos) 0031 res{i} = getfield(rs{i}, fieldname); 0032 end 0033 else % set call 0034 res = region(o, r_nos, new_data, fieldname); 0035 end 0036 0037 0038