Temperature data
이전 댓글 표시
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
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
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
2011년 11월 4일
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;
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!