I solved it myself, brute force method. In my case, I know the number of output variables I need, so the solution is a series of while loops based on a thresholding condition. In this case, example, I know that I want a new output variable as the data changes from 4.00__ to 1.00__. In otherwords, this si a jump of greater than two. Within each variable, changes in the data are less than two.
clear all
clc
% the data for variable one #1:
a = 1.001:1:4.001;
% the data for variable #2:
b = 1.002:1:4.002;
% the data for variable I want #3:
c = 1.003:1:4.003;
% concatenate the variables to make them look like my data file (one long
% array of information that needs to be broken down). If this was the real
% real data file, I would just import that data file rather than make the
% example "a", "b" and "c" vectors.:
data = [a,b,c,0]
% create indexing variable
ii = 1;
% Fill in data for the first output variable
% unless there is a big change in the data (thresholding condition), add
% the values in your data array to your first variable:
while abs(data(ii+1) - data(ii)) < 2 % condition for each indice change
aa(ii) = data(ii); % fill in the aa variable
ii = ii + 1; % increment counter
end
% if the above while condition is not true, then we've reached the last
% index of the first variable, but we didn't fill in this last index into
% our new variable yet.
aa(ii) = data(ii); % fill in the last value for the first variable
ii = ii + 1; % increment the counter
% Fill in data for the second variable
% set an "offsetting" index
n = ii;
while abs(data(ii+1) - data(ii)) < 2
jj = (ii-n) + 1; %offset the counter by your offsetting variable 'n'
bb(jj) = data(ii); % the index of your new variable will is restored
ii = ii + 1; % increment counter
end
% fill in the last value for the second output variable:
jj = (ii-n) + 1;
bb(jj) = data(ii);
ii = ii + 1; % increment the counter
% Fill in data for the third output variable
n = ii;
while abs(data(ii+1) - data(ii)) < 2
jj = (ii-n) + 1;
cc(jj) = data(ii);
ii = ii + 1; % increment counter
end
% print the output variables aa, bb, and cc to the workspace
aa
bb
jj = (ii-n) + 1;
cc(jj) = data(ii)