I have very large data files that need to be broken down based on conditions where data changes. See attached picture. The data changes somewhat predictably where the vector must be broken into new variables.
As another example, I started with this:
% Here's an example of what needs to happen
% the output variable #1:
a = 1.001:1:4.001;% the output variable #2:
b = 1.002:1:4.002;% the output 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 my real data file, I would just import that data file rather than make the example "a", "b" and "c" vectors.:
d = [a,b,c];l = length(d);for ii = 1:l % set a condition for when the data changes, make a new variable.
% I.e., when the data changes from -1 to -10, then the new variable
% should start.
if abs(d(ii+1) - d(ii)) > 1; % then make a new output variable that should start with -10
bb = d(ii) % now I dont' know where to go from here to keep adding numbers
% into bb (output variable #2). I also don't know how to
else % if the change between indices was not bigger than the threshold,
% then keep building the first output variable.
aa = a(ii); % the problem with this is that bb doesn't keep building, and you
% start building up aa again, even though you should be building a
% new variable here.
Best Answer