4.85714

4.9 | 7 ratings Rate this file 91 Downloads (last 30 days) File Size: 5.25 KB File ID: #20355
image thumbnail

Experimental (Semi-) Variogram

by Wolfgang Schwanghart

 

19 Jun 2008 (Updated 24 Nov 2011)

calculate the isotropic and anisotropic experimental (semi-) variogram

| Watch this File

File Information
Description

variogram calculates the isotropic and anisotropic experimental variogram in various dimensions.

Syntax:
    d = variogram(x,y)
    d = variogram(x,y,'pn','pv',...)

The function uses parseargs (objectId=10670) by Malcolm wood as subfunction.

Currently, the function calculates all variogram values at one step. While this is fast for small data sets (n<2000), it may fail on large data sets owing to memory constraints. So far, I do not have a good workaround. If you face memory issues, I'd suggest to sample your data using e.g. randperm.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
parseargs: Simplifies input processing for functions with multiple options
This submission has inspired the following:
variogramfit, Ordinary Kriging

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (17)
30 Jul 2009 Shazux Gharasoo

very nice program indeed. I had a question by the way. how the distance is calculated? direct distance or along X and Y streets?

02 Aug 2009 Wolfgang Schwanghart

Hi Shazux,

the distance measure used here is the euclidean distance. I guess that is what you mean by direct distance, do you?

Best regards,
Wolfgang

17 Aug 2009 Shazux Gharasoo

that was what I meant, thank you :)
one more question, how to pass the data that has been plot? i mean here:
plot(out.distance,out.val,marker)
I need to do some curve fitting on those values...

17 Aug 2009 Shazux Gharasoo

sorry, I found out that these values are saved already in variable 'd' as a structure. thanks though

26 Feb 2010 Anthony Kendall

Thanks a lot for this function, it works very well (though as you mentioned it is a bit of a memory hog, I had to subsample my data but the variogram was robust).

29 Sep 2010 Patrick A.

Like Variogramfit, it is for me an invaluable contribution. Very nice code, very nice comments, well I've learned a lot with these two pieces of code, Thanks a lot !

25 Apr 2011 oskenund  
06 Jul 2011 Kibre. T.

Very good. Does this code accept the other parameters such as nugget effect and sill?

08 Jul 2011 Wolfgang Schwanghart

@Kibre. T.

Nugget effect and sill are required when you fit a variogram model to the experimental variogram and, hence, they are not accepted as parameters here. However, you may want to try variogramfit, which enables to set initial values for a nugget model and sill.

12 Jul 2011 Marian Axente

Is there anything else we can use instead of IPDM since there is no such function on Matlab FEX

15 Jul 2011 Wolfgang Schwanghart

@ Marian and others

I am sorry that IPDM is currently not available on the FEX. You can send me a mail via the contact formular with your email and I'll send you the function then. I'll be working on a workaround next week.

Thanks for your interest,
Wolfgang

14 Oct 2011 Amy  
24 Nov 2011 jorge parra

Wolfgang,

Very good function; is possible calculate variograms at different angles, for example vertical and horizontal variograms? If you can do this how do you specify the angles and how do you plot them,
Thank you
Jorge

24 Nov 2011 Wolfgang Schwanghart

Hi Jorge. I have just uploaded a new version with a bug removed. Please take this one as soon as it is available (probably by 25 Nov 2011). Then, in order to obtain variograms for different directions, just calculate the anisotropic variogram. E.g. for obtaining variograms in 0 and 90° direction, you can do following:

d = variogram([x y],z,...
'nrbins',50,'anisotropy',true,...
'thetastep',30);

plot(d.distance,...
d.val(:,find(d.theta==0 | d.theta==pi/2)));

You may choose tighter angular bins. In this case it will be 0+-15 and 90+-15.

HTH, Wolfgang

28 Nov 2011 jorge parra

Thank you Wolfgang ,
I got both plots OK(for theta = 0 and theta = 90 degrees). Now I am trying to apply your program to a real data set but I am having some problems. The data set consist of 200 x 50 points (impedances) contained in a 2D rectangular cross section. The coordinates x and y and the impedance are arranged in three vectors, each of them of dimension 200x 50 = 10000. The function in the script file is given by:
d = variogram([x y], impedance, 'nrbins',50,'anisotropy',true, 'thetastep',30);
The error message: “ Anisotropy is only supported for 2D",

What am I doing wrong?
Jorge

28 Nov 2011 Wolfgang Schwanghart

Hi Jorge,

are those data gridded? If yes, you should call the function like this:

d = variogram([x(:) y(:)], impedance(:), 'nrbins',50,'anisotropy',true,'thetastep',30);

Best regards,
Wolfgang

18 Jan 2012 Adam  
Please login to add a comment or rating.
Updates
24 Jun 2008

removed an error in the calculation of the number of bins

09 Feb 2010

dependence on consolidator was removed,
anisotropic experimental variogram is now supported.

21 Jul 2011

Removed dependency from IPDM. Fortunately, it is even faster now on my machine. The relatively large memory overhead is still unresolved. Added subsampling option.

24 Nov 2011

removed a bug in calculating the number of angular bins for anisotropic variograms.

Tag Activity for this File
Tag Applied By Date/Time
geostatistics Wolfgang Schwanghart 22 Oct 2008 10:06:38
spatial modelling Wolfgang Schwanghart 22 Oct 2008 10:06:38
variogram Wolfgang Schwanghart 22 Oct 2008 10:06:38
dimensions Wolfgang Schwanghart 22 Oct 2008 10:06:38
kriging Wolfgang Schwanghart 09 Feb 2010 13:18:21
kriging yuli zhang 15 Mar 2011 02:24:00

Contact us at files@mathworks.com