getting the values at certain locations

so I have a list of non zero locations (for consecutive days temperature is below freezing) and i need to find the values at those locations. little example of my problem is
m= [31 34 56 21 56]
v=find(m<32)
v= [1 4]
and now what would I use to find the value at locations 1 and 4?

Answers (2)

Go back and take a different approach.
m= [31 34 56 21 56]
v = [false, m<32, false];
runstarts = strfind(v, [false true]) - 1;
runends = strfind(v, [true false]) - 1;
[runstarts(:), runends(:)]
This will give you a matrix of 2 columns in which the first column is the index of the beginning of a run and the second column is the index of the end of the run. (If the index of the beginning and end are the same, the "run" lasted only the single day.)
You can easily index these in to m to get exact temperatures, but everything after the above gets in to matters of presentation of the data rather than matters of locating the data.

Categories

Asked:

on 21 Sep 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!