function [MITprofSub]=MITprof_subset(MITprof,varargin); % [MITprofSub]=MITprof_subset(MITprof,'depth',[50 150]); % returns the subset of MITprof that has prof_depth>=50 and <150 % [MITprofSub]=MITprof_subset(MITprof,'depth',[50 150],'descr',platformName); % ... and prof_descr=platformName; MITprofSub=MITprof; fldNames=fieldnames(MITprof); nSub=(nargin-1)/2; for iSub=1:nSub; eval(['prof_sub=MITprof.prof_' varargin{(iSub-1)*2+1} ';']); range_sub=varargin{(iSub-1)*2+2}; if strcmp('descr',varargin{(iSub-1)*2+1}); KK=find(strcmp(prof_sub,range_sub)); elseif strcmp('depth',varargin{(iSub-1)*2+1}); KK=find(prof_sub>=range_sub(1)&prof_sub=range_sub(1)&prof_sub