Interpolate N-D scattered data - MATLAB griddatan - MathWorks Deutschland (2024)

Interpolate N-D scattered data

collapse all in page

Syntax

vq = griddatan(x,v,xq)

vq = griddatan(x,v,xq,method)

vq = griddatan(x,v,xq,method,options)

Description

example

vq = griddatan(x,v,xq) fitsa hypersurface of the form v = f(x) tothe sample points x with values v.The griddatan function interpolates the surfaceat the query points specified by xq and returnsthe interpolated values, vq. The surface alwayspasses through the data points defined by x and v.

example

vq = griddatan(x,v,xq,method) specifies the interpolation method used to compute vq. Options are "linear" or "nearest".

vq = griddatan(x,v,xq,method,options) specifiesa cell array of character vectors, options, tobe used in Qhull via delaunayn.

Examples

collapse all

Fit Hypersurface

Open Live Script

Interpolate a 4-D scattered data set and visualize a 3-D isosurface of the interpolated data.

Create a scattered set of sample points.

rng defaultX = 2*rand([5000 3])-1;Y = sum(X.^2,2);

Create x, y, and z grids to use as the 3-D set of query points, and interpolate the scattered data at these points.

d = -0.8:0.05:0.8;[y0,x0,z0] = ndgrid(d,d,d);XI = [x0(:) y0(:) z0(:)];YI = griddatan(X,Y,XI);

Since it is difficult to visualize 4-D data sets, use isosurface at 0.8 to visualize the interpolation result.

YI = reshape(YI, size(x0));p = patch(isosurface(x0,y0,z0,YI,0.8));isonormals(x0,y0,z0,YI,p)p.FaceColor = "blue";p.EdgeColor = "none";view(3)axis equalcamlightlighting phong

Interpolate N-D scattered data - MATLAB griddatan- MathWorks Deutschland (1)

Nearest Neighbor Interpolation

Open Live Script

Use nearest neighbor interpolation on a 3-D scattered data set.

Create a sample 3-D data set. The matrix X contains the xyz locations of the observed data, and v contains the (randomly generated) observed data. This type of data set could represent, for example, oxygen levels in ocean water at these locations.

rng defaultX = [rand(100,1) rand(100,1) rand(100,1)];v = rand(100,1);

Use nearest neighbor interpolation to approximate the value of the underlying function at some query points.

[xx,yy,zz] = meshgrid(0:0.05:1);xq = [xx(:) yy(:) zz(:)];vq = griddatan(X,v,xq,"nearest");

Plot slices of the result on top of the sample point locations.

vq = reshape(vq,size(xx));plot3(X(:,1),X(:,2),X(:,3),"r*")hold onslice(xx,yy,zz,vq,[0.3 0.6],0.5,0.5)hold off

Interpolate N-D scattered data - MATLAB griddatan- MathWorks Deutschland (2)

Input Arguments

collapse all

xSample point coordinates
matrix

Sample point coordinates, specified as a matrix. Specify x asan m-by-n matrix to represent m pointsin n-dimensional space. The sample points mustbe unique.

Data Types: double

vSample values
vector

Sample values, specified as a vector. Specify v asa vector of length m, with one value for each samplepoint (row) specified in x.

If v contains complex numbers, then griddatan interpolatesthe real and imaginary parts separately.

Data Types: single | double
Complex Number Support: Yes

xqQuery points
matrix

Query points, specified as a matrix. Specify xq asa p-by-n matrix to represent p pointsin n-dimensional space. xq isusually created from a uniform grid produced by ndgrid.

Data Types: double

methodInterpolation method
"linear" (default) | "nearest" | []

Interpolation method, specified as one of the values in thistable. These methods are both based on a Delaunay triangulation ofthe input data.

OptionDescriptionContinuity
"linear" (default)Triangulation-based linear interpolation.C0
"nearest"Nearest neighbor interpolation.Discontinuous

If method is [], then griddatan uses the default "linear" method.

Data Types: char | string

optionsQhull-specific options
cell array | [] | {''}

Qhull-specific options, specified as a cell array. For a list of supported options, see Qhull Quick Reference.

If options is [], then griddatan usesthe default options:

  • {'Qt' 'Qbb' 'Qc'} for 2-D and 3-Dinterpolations.

  • {'Qt' 'Qbb' 'Qc' 'Qx'} for interpolationsin 4+ dimensions.

If options is {''}, then griddatan doesnot use any options, not even the defaults.

Data Types: cell

Output Arguments

collapse all

vq — Interpolated values
vector

Interpolated values, returned as a vector of length p.The interpolated values in vq correspond to thequery points (rows) in xq.

Tips

  • It is not practical to use griddatan forinterpolation in dimensions higher than about 6-D, because the memoryrequired by the underlying triangulation grows exponentially withthe number of dimensions.

  • Scattered data interpolation with griddatan uses a Delaunay triangulation of the data, so can be sensitive to scaling issues in x. When this occurs, you can use normalize to rescale the data and improve the results. See Normalize Data with Differing Magnitudes for more information.

Extended Capabilities

Version History

Introduced before R2006a

See Also

delaunayn | griddata | meshgrid

MATLAB-Befehl

Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:

 

Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.

Interpolate N-D scattered data - MATLAB griddatan- MathWorks Deutschland (3)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

Contact your local office

Interpolate N-D scattered data - MATLAB griddatan
- MathWorks Deutschland (2024)
Top Articles
Latest Posts
Article information

Author: Rob Wisoky

Last Updated:

Views: 6359

Rating: 4.8 / 5 (68 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Rob Wisoky

Birthday: 1994-09-30

Address: 5789 Michel Vista, West Domenic, OR 80464-9452

Phone: +97313824072371

Job: Education Orchestrator

Hobby: Lockpicking, Crocheting, Baton twirling, Video gaming, Jogging, Whittling, Model building

Introduction: My name is Rob Wisoky, I am a smiling, helpful, encouraging, zealous, energetic, faithful, fantastic person who loves writing and wants to share my knowledge and understanding with you.