Home > polypedal > cartperturb > oneBigArray.m

# oneBigArray

## PURPOSE

Collect multiple data runs from structure into one big array.

## SYNOPSIS

function [data,frame] = oneBigArray(s,F)

## DESCRIPTION

``` Collect multiple data runs from structure into one big array.
Assumes s has the following fields:
data = [num_states] x [traj_length] array containing data to collect
frames = [num_runs] x 3 array with length(s(i).data) = s(i).frames(3)-s(i).frames(1)+1
and s(i).frames(2) indicating frame to match up between runs```

## CROSS-REFERENCE INFORMATION

This function calls:
This function is called by:

## SOURCE CODE

```0001 % Collect multiple data runs from structure into one big array.
0002 % Assumes s has the following fields:
0003 %   data = [num_states] x [traj_length] array containing data to collect
0004 %   frames = [num_runs] x 3 array with length(s(i).data) = s(i).frames(3)-s(i).frames(1)+1
0005 %     and s(i).frames(2) indicating frame to match up between runs
0006 function [data,frame] = oneBigArray(s,F)
0007
0008 if nargin < 2
0009   F = 'data';
0010 end
0011
0012 % Determine size of returned array
0013 frames = vertcat(s(:).frames);
0014 % m = max(frames(:,2) - frames(:,1));
0015 % M = max(frames(:,3) - frames(:,2));
0016
0017 m = max(frames(:,2));
0018 M = max(frames(:,3));
0019
0020 % Allocate space for array
0021 k = 1;
0022 while size(s(k).(F),1) == 0
0023   k = k+1;
0024 end
0025 data = nan(length(s), m + M, size(s(k).(F),1));
0026
0027 % Loop through runs
0028 for f = 1:length(s)
0029   % Loop through state variables
0030   for v = 1:size(data,3)
0031     if ~isempty(s(f).(F)) && diff(s(f).frames([1,end])) > 0
0032       % Collect data from run
0033       fr = (s(f).frames(1):s(f).frames(3));
0034       data(f,fr + m-s(f).frames(2),v) = s(f).(F)(v,fr)';
0035 %       data(f,fr + m-s(f).frames(2),v) = s(f).(F)(v,:)';
0036     end
0037   end
0038 end
0039
0040 frame = m;```

Generated on Mon 02-Aug-2010 16:44:38 by m2html © 2003