>> x = [400, 200; 400, 200]
x =
400 200
400 200
>> y = [500, 300; 500, 300]
y =
500 300
500 300
>> z = [-54.323, -42.498; -26.083, -15.099]
z =
-54.3230 -42.4980
-26.0830 -15.0990
>> xi = [300, 100; 300, 100]
xi =
300 100
300 100
>> yi = [400, 200; 400, 200]
yi =
400 200
400 200
>> zi = interp2(x,y,z,xi,yi)
??? Error using ==> interp2
X and Y must be matrices produced by MESHGRID. Use GRIDDATA instead
of INTERP2 for scattered data.
>> help griddata
GRIDDATA Data gridding and surface fitting.
ZI = GRIDDATA(X,Y,Z,XI,YI) fits a surface of the form Z = F(X,Y)
to the data in the (usually) nonuniformly-spaced vectors (X,Y,Z)
GRIDDATA interpolates this surface at the points specified by
(XI,YI) to produce ZI. The surface always goes through the data
points. XI and YI are usually a uniform grid (as produced by
MESHGRID) and is where GRIDDATA gets its name.
XI can be a row vector, in which case it specifies a matrix with
constant columns. Similarly, YI can be a column vector and it
specifies a matrix with constant rows.
[XI,YI,ZI] = GRIDDATA(X,Y,Z,XI,YI) also returns the XI and YI
formed this way (the results of [XI,YI] = MESHGRID(XI,YI)).
[...] = GRIDDATA(...,'method') where 'method' is one of
'linear' - Triangle-based linear interpolation (default).
'cubic' - Triangle-based cubic interpolation.
'nearest' - Nearest neighbor interpolation.
'v4' - MATLAB 4 griddata method.
defines the type of surface fit to the data. The 'cubic' and 'v4'
methods produce smooth surfaces while 'linear' and 'nearest' have
discontinuities in the first and zero-th derivative respectively.
All
the methods except 'v4' are based on a Delaunay triangulation of
the
data.
See also GRIDDATA3, GRIDDATAN, DELAUNAY, INTERP2, MESHGRID.
>> zi = griddata(x,y,z,xi,yi)
Warning: Duplicate x-y data points detected: using average of the z
values.
(Type "warning off MATLAB:griddata:DuplicateDataPoints" to suppress
this warning.)
> In C:\MATLAB6p5\toolbox\matlab\polyfun\griddata.m at line 59
??? Error using ==> delaunayn
Not enough unique points to do tessellation.
Error in ==> C:\MATLAB6p5\toolbox\matlab\polyfun\griddata.m
(linear)
On line 100 ==> tri = delaunayn([x y]);
Error in ==> C:\MATLAB6p5\toolbox\matlab\polyfun\griddata.m
On line 74 ==> zi = linear(x,y,z,xi,yi);
The matrices xi and yi must represent a rectangular grid:
infact if I consider the point xi(1,1) yi(1,1) is equal to the point
xi(2,1) yi(2,1): this thing in a grid is impossible!
I think that also the matix x and y are not coerent with interp2;
a little question: are you searching an interpolant surface or curve?
Spero di averti dato 1 soluzione, non č unica ma esiste ;->
Buon Lavoro e W l'Italiano
MatLab
RoB
Scusa ma griddata mi dice che devo usare piů variabili in ingresso, e
solo vx e vy non bastano!!
[X,Y]=meshgrid(vx,vy);
e intendevo suggerirti di usare griddata per l'interpolazione invece che
interp2, cioč
Z=griddata(x,y,z,X,Y);
Scusa tanto per la mancanza... spero che ora sia ok. Saluti