Home > functions > internal > dsCheckCovaryWrapper.m

dsCheckCovaryWrapper

PURPOSE ^

Calls checkCovary and handles all the set up automagically.

SYNOPSIS ^

function [effective_vary_indices, linked_inds] = dsCheckCovaryWrapper(data,varargin)

DESCRIPTION ^

 Calls checkCovary and handles all the set up automagically.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [effective_vary_indices, linked_inds] = dsCheckCovaryWrapper(data,varargin)
0002     % Calls checkCovary and handles all the set up automagically.
0003     
0004     % First, remove any data in data(1...N) that is empty (e.g. skipped by
0005     % the simulator; if you pass DynaSim a varied statement of the form
0006     % (RS,FS),1:2, data will actually be 1:4 with off-diagonal entries
0007     % empty).
0008     % Note: This function is likey no longer used (at least not for dsPlot2
0009     % an has been replaced by other functions (see dsGetCovariedDs).
0010     labels = data(1).labels;
0011     inds = arrayfun(@(s) ~isempty(s.(labels{1})),data);
0012     data = data(inds);
0013 
0014     % % First, if there are any covaried axes, merge them together.
0015     % 1. Initialize variables for checkCovary
0016     vary_labels = data(1).varied; % data(1).simulator_options.vary;
0017     no_vary_labels = length(vary_labels);
0018     vary_params = cell(length(data), no_vary_labels);       % First assume they can be anything (numerics, strings, etc., so store them as a cell array first)
0019     vary_vectors = cell(no_vary_labels, 1);
0020     vary_lengths = nan(no_vary_labels, 1);
0021 
0022     % 2. Populate variables for checkCovary
0023     % get varied params
0024     for v = 1:no_vary_labels
0025         for i = 1:length(data)
0026             vary_params{i, v} = data(i).(vary_labels{v});
0027         end
0028     end
0029     
0030     % Format vary_params appropriately
0031     if iscellnum(vary_params);
0032         % If they're all numerics, convert to matrix
0033         vary_params = cell2mat(vary_params);
0034     elseif iscell(vary_params) && ~iscellstr(vary_params)
0035         % If its a cell, but not full of strings, convert it to all
0036         % strings. This is because checkCovary can only do comparisons
0037         % between all numerics and all chars, but can't compare chars to
0038         % numerics.
0039         for j = 1:numel(vary_params)
0040             if isnumeric(vary_params{j})
0041                 vary_params{j} = num2str(vary_params{j});
0042             end
0043         end
0044     end
0045     
0046     for v = 1:no_vary_labels
0047         vary_vectors{v} = unique(vary_params(:, v));
0048         vary_lengths(v) = length(vary_vectors{v});
0049     end
0050 
0051     % 3. Run checkCovary
0052     [effective_vary_indices, linked_inds] = dsCheckCovary(vary_lengths, vary_params, varargin{:});
0053     %dsIdCovaried(vary_params);
0054 end

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