To my first question, I need a code that displays all the constant variables that are atleast 5 in a row excluding 0. The first code shows only the max constant and includes 0. Any help would be great. Thanks
No products are associated with this question.
Justin. You'll want a very handy function, findseq. It can be downloaded on the file exchange. http://www.mathworks.com/matlabcentral/fileexchange/28113-findseq
The code you'll have to use is as follows:
[vals, start, stop, len] = findseq(A); len(vals == 0) = -inf; % Exclude 0s ind = (len >= 5); % Find the ones with 5 or more values. vals(ind) % Report the value start(ind) % Report the start index stop(ind) % Report the stop index len(ind) % Report the length