How do I select data based on multiple indexes?
12 views (last 30 days)
Show older comments
Shayma Al Ali on 1 Oct 2021
Answered: Kelly Kearney on 1 Oct 2021
I have a data set called 'total_backscatternight'. I have three flags, 'water_data','Perp_saturationdata','Par_saturationdata', where I would like to select data from 'total_backscatternight' based on those three flags. However, once I select data after one flag, I get the error that 'Index exceeds the number of array elements (43696)'. How do I select the data based on all three flags?
%find data in ocean
water_data=find(landwatermask==7 | landwatermask==0);
The files have been uploaded in different files.
Kelly Kearney on 1 Oct 2021
Assuming that the landwatermask, PerpSurface_saturationflag, and ParSurface_saturationflag matrices are all the same size, and they have the same number of elements as rows in total_backscatternight and perp_backscatternight:
mask = (landwatermask == 7 | landwatermask == 0) & ...
PerpSurface_saturationflag==0 & ...
t_backscatternight = total_backscatternight(mask(:),562);
p_backscatternight = perp_backscatternight(mask(:),562);
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!