MATLAB: Look up elements in a table

searchtable

I have a table like this:
Date Min Max Mode
1 10 14 12
2 12 17 15
3 32 53 50
4 20 25 23
5 16 20 16
6 12 15 14
7 89 98 90
8 57 63 60
9 45 95 73
10 49 70 68
How do I search the table within a specific range?
For example, if I wanted to search the maximum number in the Max column from dates 3 to 8, I'd get 98 and date 7.

Best Answer

mask = find(Yourtable.Date >= 3 & Yourtable.Date <= 8);
[maxval, subsetidx] = max(Yourtable.Max(mask));
maxdate = Yourtable.Date(mask(subsetidx));
Now maxval located on maxdate
Alternately:
mask = Yourtable.Date >= 3 & Yourtable.Date <= 8;
subset = Yourtable(mask);
[maxval, subsetidx] = max(subset.Max);
maxdate = subset.Date(subsetidx);
This is cleaner coding, but creates a complete sub-table containing all of the table entries selected, which in the case of larger table an large search ranges could take a lot of resources.