Temperature data
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Wayne King
el 4 de Nov. de 2011
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 comentarios
Walter Roberson
el 4 de Nov. de 2011
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
el 4 de Nov. de 2011
[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 comentarios
Ver también
Categorías
Más información sobre NaNs en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!