Find index of value extracted from subset in larger set
3 views (last 30 days)
I have a dataset in the form of a struct with two fields - each field is a double with 1,500 x 1 values. One field is t values, the other is p values. These are values are matched across rows. I want to find the minimum p value and then the corresponding t value within multiple subsets across these 1,000 values. For example, the minimum p value between rows 325:400 e.g. p value 0.04 in row 357 and the correspond t value which will then be in row 357 in the t values field. I can find the minimum p value within a subset (rows 325:400) but I don't know how to then get the index of this p value within the larger dataset so I can extract the corresponding t value. The below code gives me the index of the p value within the subset only i.e. row 32 (357-325=32) . I can try using find as below, but there are mutlple datapoints in the larger set that will match this p value. Is there a way to get the index within the larger dataset?
p = min(pvalue(325:400));
[idx1 idx2] = find(p == (pvalue));
t = tvalue(idx1)