Temperature data
5 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(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.
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;
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!