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
2011-9-21
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 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!