File Exchange

## griddataLSC

version 1.0.0.8 (4.38 KB) by Jack

### Jack (view profile)

Least Squares Collocation - data interpolation, empricial covariance estimation & function fitting

Updated 10 Dec 2018

griddataLSC can be used interpolate data using least squares collocation.
It offers the choice of 6 covariance functions;
1. the 3-D logarithmic covariance function
2. the 2-D exponential covariance function
3. the 2-D Reilly covariance function
4. the 2-D triangular covariance function
5. the 2-D Gaussian covariance function
6. the 2-D second order Markov covariance function
The covariance function parameters can be specified or they can be fitted to estimated empirical covariance values.
________________________________________________________________________
How to use griddataLSC
2-D observation data:
.............G (x,y)+N(X,Y)_________G(x,y)+N(X,Y).........
............................/........../............/...............................
........................../_G (x_i,y_i)?__/................................
......................../.........../............/..................................
G(x,y)+N(X,Y)/______/______/G(x,y)+N(X,Y)..............
for some observation data G made a locations X,Y with estimated noise variances N (~=0) (for each measurement G) griddataLSC can interpolate G by least squares collocation to locations Xi,Yi using one of the following covariance functions,
- the exponential,
- Reilly,
- triangular,
- Gaussian or
- Second order Markov model
to obtain values Gi, and determine the covariance function parameters C0 and D ;
[Gi,C0,D]=griddataLSC('exp',X,Y,G,N,Xi,Yi); for exponential
[Gi,C0,D]=griddataLSC('Reilly',X,Y,G,N,Xi,Yi); for Reilly
[Gi,C0,D]=griddataLSC('tri',X,Y,G,N,Xi,Yi); for triangular
[Gi,C0,D]=griddataLSC('gaus',X,Y,G,N,Xi,Yi); for Gaussian
[Gi,C0,D]=griddataLSC('som',X,Y,G,N,Xi,Yi); for Second order Markov
to also out put the estimated empirical covariance values the users can specify the following additional output arguments
e.g. for exponential

[Gi,C0,D,Covariancevalues,CovarianceDistance]=griddataLSC('exp',X,Y,G,N,Xi,Yi);

a figure of the empirical covariance values and the fitted model can also be output using the additional input arguments

e.g. for exponential

[Gi,C0,D,Covariancevalues,CovarianceDistance]=griddataLSC('exp',X,Y,G,N,Xi,Yi,'covfigure');

if C0,D are already known and you want to specify them, use
e.g. for exponential
[Gi]=griddataLSC('exp',X,Y,G,N,Xi,Yi,C0,D);

3-D observation data:
..............G (x,y,z)+N(x,y,z)_________G(x,y,z)+N(x,y,z)...
.............................../............/............/.............................
............................./______/______/...............................
.........................../............/............/.................................
G(x,y,z)+N(x,y,z)/______/______/G(x,y,z)+N(x,y,z).........
..........................._____________...................................
........................./............/............./...................................
......................../_G (x_i,y_i,zi)?_/....................................
....................../............/............./......................................
...................../______/______/.......................................

for some observation data G made a locations X,Y and Z with estimated noise variances N (~=0) (for each measurement G) griddataLSC can interpolate G to locations Xi,Yi,Zi using a 3-D logarithmic covariance function fitted to the data emprical covariance values,

[Gi,C0,D,T]=griddataLSC('log',X,Y,Z,G,N,Xi,Yi,Zi);

to out put the empirical covariance values, use the following additional output arguments

[Gi,C0,D,T,Covariancevalues,CovarianceDistance]=griddataLSC('log',X,Y,Z,G,N,Xi,Yi,Zi);

to output a figure of the empirical covariance values and the fitted model,use the following additional input arguments

[Gi,C0,D,T,Covariancevalues,CovarianceDistance]=griddataLSC('log',X,Y,Z,G,N,Xi,Yi,Zi,'covfigure');

if C0,D,T are already known or the user would like to specify them, then the following can be used
[Gi]=griddataLSC('log',X,Y,Z,G,N,Xi,Yi,Zi,C0,D,T);

This can be be used to upward/downward continue gravity observations and simultaneously grid the data.

### Cite As

Jack (2019). griddataLSC (https://www.mathworks.com/matlabcentral/fileexchange/57342-griddatalsc), MATLAB Central File Exchange. Retrieved .

Jack

### Jack (view profile)

Thanks for picking this up @giometar
I have updated the code to resolve these errors.

giometar

### giometar (view profile)

Hi Jack
There is maybe error in code:
Line 307:
Gouit=LSCSecondorderMarkov(Xi,Yi,X,Y,C0,D,N,G);
Gout=reshape(Gouti,size(varargin{6}));

I also get error massage when using Reilly:
>> griddataLSC('Reilly',X,Y,Gx,N,Xi,Yi)
Matrix dimensions must agree.

Error in griddataLSC/LSCReilly (line 398)
Csz=(1-0.5*(r./D).^2).*exp(-0.5*(ri./D).^2);

Error in griddataLSC (line 194)
Gouti=LSCReilly(Xi,Yi,X,Y,C0,D,N,G);

X,Y,G,N are 2742x1
Xi,Yi are 19564x1

Marko Peric

Marko Peric

Great work!

giometar

Apollos Tukka

Good work