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?

답변 (2개)

Walter Roberson
Walter Roberson 2011년 9월 21일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

질문:

2011년 9월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by