MATLAB: How to extract certain values from a dataset representing a topographic profile

extracting values

Hi,
I actually already did it by picking the needed datapoints manually but thats just way too pedantic and laborious!
The data of my profile looks like in the image now – footwall and hangingwall have three best fit lines (or one best fit line, upper bound and lower bound) – the best fit is set up from all datapoints (of the footwall and the hangingwall resp.), the upper bounds are set up of the 10 furthest, manually chosen datapoints above the first best fit line, the lower bounds are set up of all datapoints below the best fit.
I started by setting the condition that, for the upper bound, matlab has to choose all datapoints that are greater than the best fit line (or smaller for the lower bound):
UBFw = footwall > best_fit_fw; % condition that picks all datapoints that are greater than the best fit line sortedUBFw = sortrows(UBFw,-2) % sorting rows and extracting 10 largest values UBFw10 = sortedUBFw(1:10,:)
But now I have no idea how to convert the logical array back to the actual values…. Or is it easier to use the dist function at some point? (did that at some point but I have no clue what the values that I get there actually display!)…
Thanks in advance! Schirin

Best Answer

It is very easy to get actual values from logicals. Check the below example.
x = rand(20,1) ; % some random data
idx = x>0.5 ; % get indices of x greater then 0.5, a lofgical array
iwant = x(idx) ;
You can extract your data like above, if you know the logical indices. Hope this helps.
Related Question