Temperature data

조회 수: 5 (최근 30일)
ricco
ricco 2011년 11월 4일
Does anyone know of the best way to do the following:
I have temperature data for a lake which is taken every 2 meters, the data is located in a matrix with each 2 meter measurement in a separate column and each row representing a different time. What would be the best way to include a statement which states that if any value varied more than 2 degrees Celsius from the next column (in the same row) to be counted as NaN?
Any suggestions would be great!
cheers

답변 (2개)

Wayne King
Wayne King 2011년 11월 4일
Is it "varied more than 2" in absolute value? or just greater than? Let X be the data matrix.
Y = abs(diff(X'));
X(Y>2) = NaN;
Not sure what value you want to replace with the NaN.
For example if the first column is 7 and the second column is 2, do you want to put a NaN in the first column??
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 11월 4일
Careful, diff(X) will be smaller than X: you would need to pad Y to use it it as a logical index.
And be careful because you transposed X to get Y but then you index X at the untransposed Y.
Using diff(X,2) would avoid the transpose.
ricco
ricco 2011년 11월 4일
During some instances the temperatures vary by up to 7 degrees celsius depending on the time of year but they dont vary by 2 degrees with respect to the next depth (i.e. next column).
So, ideally the location of the NaN would depend on the other values in the same row. So, if the first column is 7 then the second is 2 then the third is 8 then i would need the second column to be NaN.
The threshold value doesnt have to be 2 degrees but the temperatures do not vary more than 2 with respect to the next depth (i.e. column)unless there is a fault in which case im trying to remove them.
cheers

댓글을 달려면 로그인하십시오.


Andrei Bobrov
Andrei Bobrov 2011년 11월 4일
[a,b] = find(diff(yourdata,1,2)>2)
yourdata(sub2ind(size(yourdata),a,b+1)) = nan
variant 2
s = size(yourdata);
z = zeros(s(1),1);
t1 = [z yourdata z];
m = arrayfun(@(x)median(reshape(t1(x, hankel(1:3,3:s(2)+2)),3,[]) ),1:s(1),'un',0);
tst = abs(yourdata - cell2mat(m.')) > 2;
yourdata(tst) = nan;

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by