griddata problems in Matlab 6.0

griddata problems in Matlab 6.0

Post by T.Kie » Fri, 06 Jul 2001 19:21:21



Hello

I encountered problems when I tried to create a surface with unevenly
spaced 3D data points.(x,y,z)

   [x_grid,y_grid] = meshgrid(unique(x),unique(y));
   z_grid = griddata(x , y , z , x_grid, y_grid);
   mesh(x_grid,y_grid,z_grid)

I use this to read out data, e.g. for y=foo and z=0

   x0 = griddata(y_grid,z_grid,x_grid,foo,0);

This used to work fine when I used Matlab 5.2, but since I upgraded to
Matlab 6.0 my programm crashes.
The data generated by griddata seems to have holes respectively NaN's.

Did I miss something about the usage of the "new" griddata function ?
Does anybody know a workaround for this problem ?

Any help is appreciated

Thiemo

 
 
 

griddata problems in Matlab 6.0

Post by zhip.. » Sat, 07 Jul 2001 00:06:25


Could you please send me the data so that I can take a look at it? Without the
data, it is very hard for us to find out what's wrong. Thanks.

------
Zhiping You
The MathWorks Inc.


> Hello

> I encountered problems when I tried to create a surface with unevenly
> spaced 3D data points.(x,y,z)

>    [x_grid,y_grid] = meshgrid(unique(x),unique(y));
>    z_grid = griddata(x , y , z , x_grid, y_grid);
>    mesh(x_grid,y_grid,z_grid)

> I use this to read out data, e.g. for y=foo and z=0

>    x0 = griddata(y_grid,z_grid,x_grid,foo,0);

> This used to work fine when I used Matlab 5.2, but since I upgraded to
> Matlab 6.0 my programm crashes.
> The data generated by griddata seems to have holes respectively NaN's.

> Did I miss something about the usage of the "new" griddata function ?
> Does anybody know a workaround for this problem ?

> Any help is appreciated

> Thiemo


 
 
 

1. Problem / potential bug with compiled griddata in Matlab 5.3

I am getting odd and incorrect results using griddata with
the C++ Math
Library in Matlab 5.3.

In Matlab, griddata seems to work fine, producing the
following results,
for example.
? x = [1 -1 -1 1]
? y = [1 1 -1 -1]
? z = [1 1 1 1]
? [Xi,Yi] = meshgrid(-1:.5:1,-1:.5:1)
? Zi = griddata(x,y,z,Xi,Yi)

Zi =

     1     1     1     1     1
     1     1     1     1     1
     1     1     1     1     1
     1     1     1     1     1
     1     1     1     1     1

However, when using the C++ library, performing the exact
same sequence
of events produces incorrect results, for example, the
snippet:

        double x[5] = {1,-1,-1,1};
        double y[5] = {1,1,-1,-1};
        double z[5] = {1,1,1,1};
        mwArray xm = mwArray(1,4, x);
        mwArray ym = mwArray(1,4, y);
        mwArray zm = mwArray(1,4, z);
        mwArray rangex = mwArray(-1, .5, 1);
        mwArray rangey = mwArray(-1, .5, 1);
        mwArray Xi,Yi,Zi;
        Xi = meshgrid(&Yi,rangex,rangey);
        Zi = griddata(xm,ym,zm,Xi,Yi);
        cout << xm << ym << zm << Zi;

returns:

  [
         1       -1       -1        1
  ]

  [
         1        1       -1       -1
  ]

  [
         1        1        1        1
  ]

  [
    1.00000   1.61880   1.84965   1.61880   1.00000 ;
    1.61880   2.10494   2.28840   2.10494   1.61880 ;
    1.84965   2.28840   2.44608   2.28840   1.84965 ;
    1.61880   2.10494   2.28840   2.10494   1.61880 ;
    1.00000   1.61880   1.84965   1.61880   1.00000
  ]

This matrix is incorrect, and the values are much larger
then they
should be, as if a peak was inserted into my data set.
Further, for
some x,y, and z sets the returned results are correct, while
other
examples are not.

Am I doing something wrong, or is this a correctable bug?

Jason Fama

**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****

2. appleshare help

3. Matlab 6.0 on Pentium 4 under Win XP - Problems

4. My network & openview

5. Editor MATLAB 6.0 (parentheses problem)

6. Plato software for X-10

7. Installation problem in XP with Celeron 2 Ghz Matlab ver 6.0

8. VS.NET crashes at startup

9. Problems using Borland C++ Builder 6.0 and Matlab R13

10. MATLAB 6.0 Rel 12 installation problem

11. Installation problem with MATLAB 6.0

12. MATLAB 6.1 / Visual C++ 6.0 integration problem

13. problems with jdk version with Matlab 6.0 under win98