How to implement kriging in Matlab?
Ältere Kommentare anzeigen
I need to perform kriging in Matlab based on three borehole samples.

Numbers for soil layers indicate depth from ground zero, boreholes - position on model.
The outcome should look something like this (already done that in Zsoil):

Any ideas how to perform this?
3 Kommentare
Image Analyst
am 9 Jan. 2022
Are you using commas for decimal points instead of periods? Like (x,y) = 7,5 -- okay that means commas are commas. But SoilLevel1 = (3, 27) - what the heck does that mean? Is the value 3.27? Or do you have two values: 3 and 37? And if two values, what does each value represent?
KarolN
am 9 Jan. 2022
Phillip coupe
am 23 Jul. 2024
no need to be rude a comma is a common point in europe. to auther though thsi is matlab if you are using decimalisation you must use decimal points. commas are seperators in matlab and will fail if you mix and match
Antworten (2)
the cyclist
am 8 Jan. 2022
0 Stimmen
4 Kommentare
the cyclist
am 8 Jan. 2022
@KarolN wrote the following as an "answer", but I am moving it here, because it was actually a comment on my answer:
I'd like to point out that https://www.mathworks.com/matlabcentral/fileexchange/29025-ordinary-kriging is out of date, as currently neither nargin or nargout aren't supported in the script. As for my original question, I hoped for some hints how to implement my samples, I know there are many kriging tools but I simply don't have time to rewrite their code or figure how it works.
the cyclist
am 8 Jan. 2022
Sorry, but I am completely ignorant of this method, so I can't really give you a better "hint" than providing you with a pointer to code where someone else solved the problem. I would have hoped that this would give you a solid headstart on writing your own.
I hadn't noticed how old the submission I mentioned was. There are other kriging examples in the File Exchange, that look more up-to-date. Maybe they will be more helpful.
KarolN
am 8 Jan. 2022
Image Analyst
am 8 Jan. 2022
0 Stimmen
I believe I saw somewhere in the documentation that scatteredInterpolant did kriging. Attached is a demo.
10 Kommentare
KarolN
am 8 Jan. 2022
Image Analyst
am 8 Jan. 2022
It should work. As well as griddedInterpolant(). Not sure why you couldn't adapt it to your data. Can you attach your data so we can read it in (I don't want to type in stuff from your image.)
Also, I don't understand your desired output image. What is displayed on the vertical axis and horizontal axis and how does that relate to the boreholes and soil layers?
KarolN
am 8 Jan. 2022
KarolN
am 8 Jan. 2022
Image Analyst
am 8 Jan. 2022
It doesn't. Read the documentation - nothing in there about requiring an image or a PNG image. It just deals with 2-D data -- ANY kind of 2-D data. But I don't know what your two dimensions in your image represent because the axes are not labeled and you didn't answer my question. Again:
What is displayed on the vertical axis and horizontal axis and how does that relate to the boreholes and soil layers?
Image Analyst
am 9 Jan. 2022
So is this what you have:
sample.name = 'Borehole nr 1';
sample.location = 7.5;
sample.depth = [3.27 0 8.95 12.2]
sample(2).name = 'Borehole nr 2';
sample(2).location = 17.2;
sample(2).depth = [2.52 0 8.68 12.2]
sample(3).name = 'Borehole nr 3';
sample(3).location = 30.2;
sample(3).depth = [1.53 4.58 8.47 12.2]
x = [sample.location]
soilLevels = vertcat(sample.depth)'
for k = 1 : size(soilLevels, 1)
thisLevel = soilLevels(k, :);
plot(x, thisLevel, '.-', 'LineWidth', 2, 'MarkerSize', 20)
hold on
end
grid on
xlabel('x distance', 'fontSize', fontSize)
ylabel('Depth of top of layer', 'fontSize', fontSize)
title('Soil depths as function of location', 'fontSize', fontSize)
legend('Soil 1', 'Soil 2', 'Soil 3', 'Soil 4', 'location', 'west')
I just don't see how it makes sense to interpolate. Like what would be in the graph for x=17.2 between 2.52 and 8.68? Everything between the blue line and the yellow line will be soil 1 (the blue) right? Because from the top of soil 1 to the top of the next soil is all soil 1, right?

Wolfgang Schwanghart
am 12 Jan. 2022
Actually, I don't understand why you need kriging here. The figure created by Zsoil shows a linear interpolation of the individual depths above which soils are classified into the respective soil layers. Kriging won't help here, inparticular since you would need to have a variogram.
KarolN
am 12 Jan. 2022
Kategorien
Mehr zu Agriculture finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
