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 件)

Fangjun Jiang
Fangjun Jiang 2011 年 9 月 21 日

0 投票

data=m(v)
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 ExchangeResizing 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