How to change and plot a variogram cloud in a empirical variogram
2 ビュー (過去 30 日間)
古いコメントを表示
For the ones that likes images, here is my problem on picture.
I would like to put the values from Matrix C into 30 bins and have a point which represent the mean of each bin in order to get an empirical variogram. I think I got the code of how to create bins but I have no ideas how to plot the whole.
Can somebody give me a hand? Cheers
% Creation of a new matrix with all points against each other. % Calculation of the distance between two points (diagonal of the matrix=0
dist = zeros( length(x), length(x) ); angle = zeros( length(x), length(x) );
for i=1: length(x) for j=1: length(x) deltaX = x(i)-x(j); deltaY = y(i)-y(j);
dist (i,j) = sqrt( deltaX^2 + deltaY^2 );
% Calculation of the angle in degrees
angle (i,j) = atan(deltaY / deltaX) * 180 / pi;
end
end
A = dist;
% Take half of the symetric matrix B = sparse(triu(A)); C = full(B);
% Save matrices save('A.mat', 'A'); save('B.mat', 'B'); save('C.mat', 'C');
% Replace all zero numbers by nan C(C == 0) = nan;
% Same code as above to create a matrix of same dimensions but with the % square difference of snow depth (sdepth)
sdepth = zeros( length(x), length(x) );
for i=1: length(x) for j=1: length(x)
deltaZ = z(i)-z(j);
sdepth (i,j) = deltaZ^2;
end
end
D = sdepth;
% Take half of the symetric matrix E = sparse(triu(D)); F = full(E);
% Save matrices save('D.mat', 'D'); save('E.mat', 'E'); save('F.mat', 'F');
% Replace all zero numbers by nan F(F == 0) = nan;
% Calculation of the number of pair distance in the C matrix by calculating % the number of arrays in C minus the number of nan Nk = numel(C) - sum(sum(isnan(C)));
MaxValue = max(C(:));
% Dividing the distance numbers from matrix C in Bins
a = C(:); %split into a and b b = F(:);
topEdge = 100; % define limits botEdge = 0; % define limits numBins = 30; % define number of bins
binEdges = linspace(botEdge, topEdge, numBins+1);
[h,whichBin] = histc(a, binEdges);
for i = a:numBins flagBinMembers = (whichBin == i); binMembers = b(flagBinMembers);
if any(isnan (a))
continue
binMean(i) = mean(binMembers);
end
end
% The variogram cloud is given by scatter(C(:),F(:));
0 件のコメント
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!