Find longest consecutive sequence in 3d matrix
1 次查看(过去 30 天)
显示 更早的评论
I have a large 3d matrix (latitude x longitude x time) and need to find the longest consecutive time sequence of values <=1 for each latitude/longitude pair. I have a dummy code that works on 1d data, but I am struggling to translate it to my 3d data. Also attaching a smaller piece of my 3d data file. Any help appreciated.
Dummy 1d code:
x = [0.1 1 0.1 0.11 0.3 3 0.1 11 0.3 0.3 0.3 0.13 10 1 0.3 3 3 0.1 0.1 3 3]; %made up numbers
x(x <= 1) = 0; % setting al values <=1 to 0
f = find(diff([1,x,1]==0));
p = f(1:2:end-1); % Start indices
y = f(2:2:end)-p; % Consecutive zeros
dry_max = max(y); %calculate longest sequence of 0s
3 个评论
Dyuman Joshi
2021-11-24
How exactly do you want to find the longest consecutive sequence in 3D data? What will be the order of the sequence? Can you show an example?
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!