Info
此问题已关闭。 请重新打开它进行编辑或回答。
matrix
2 次查看(过去 30 天)
显示 更早的评论
I have a matrix (100000x16) where the columns refer to depths and the rows refer to days and the data is of temperature. Some of the data is faulty i.e. gives readings which are obviously wrong. If every row is a measurement taken every 4 minutes how is it possible to state that if any temperature varies by one degree compared to the next measurement (i.e. the next row) to change it to nan?
cheers
0 个评论
回答(2 个)
Robert Cumming
2011-11-17
something like:
data(data(2:end,:)-data(1:end-1,:)>1)=NaN
3 个评论
Robert Cumming
2011-11-17
it should still work with NaN in your matrix - when you say it doesn;t seem to work - do you get an error message?
Walter Roberson
2011-11-17
Robert's suggestion of
data(data(2:end,:)-data(1:end-1,:)>1)=NaN
should be close, but his logical matrix will be one element short, which will lead to difficulties.
Ricco, you need to define specifically: when you have two consecutive values that differ by more than 1 degree, is it the first value that should be set to NaN, or the second value? The choice will determine whether Robert's logical array needs to be padded at the beginning or the end.
Also, there should be an abs() wrapped around the difference calculation.
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!