Home > functions > internal > dsCropData.m

dsCropData

PURPOSE ^

CROPDATA - Crops DynaSim data structre

SYNOPSIS ^

function data_out = dsCropData(data,inds,varargin)

DESCRIPTION ^

CROPDATA - Crops DynaSim data structre

 Usage:
   data_out = dsCropData(data,'option',value)

 Inputs:
   - data: DynaSim data structure (see dsCheckData)
   - inds: data points to retain

 Outputs:
   - data_out: data structure with all data cropped

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function data_out = dsCropData(data,inds,varargin)
0002 %CROPDATA - Crops DynaSim data structre
0003 %
0004 % Usage:
0005 %   data_out = dsCropData(data,'option',value)
0006 %
0007 % Inputs:
0008 %   - data: DynaSim data structure (see dsCheckData)
0009 %   - inds: data points to retain
0010 %
0011 % Outputs:
0012 %   - data_out: data structure with all data cropped
0013 
0014 %% 1.0 Check inputs
0015 
0016 data = dsCheckData(data, varargin{:});
0017 % note: calling dsCheckData() at beginning enables analysis function to
0018 % accept data matrix [time x cells] in addition to DynaSim data structure.
0019 
0020 %% do the cropping
0021 
0022 data_out = data;
0023 for i = 1:length(data)
0024     % Identify all fields in data containing simulated output
0025     labels = data(i).labels;
0026 
0027     % Sweep through these fields and take average
0028     for j = 1:length(labels)
0029         if ~isempty(data(i).(labels{j}))
0030             data_out(i).(labels{j}) = data(i).(labels{j})(inds,:);
0031         end
0032     end
0033 end
0034 
0035 end

Generated on Tue 12-Dec-2017 11:32:10 by m2html © 2005