[scilab-Users] gridddata

Mathieu Dubois mathieu.dubois at limsi.fr
Wed Feb 17 23:00:39 CET 2010


Hello Dave,
> I’m trying to convert a MATLAB script into Scilab and am struggling to
> find a replacement for ‘griddata’. Unfortunately, I wasn’t very involved
> in the original coding and am a relative novice to Scilab/Matlab!
>
I don't know much about interpolation of data but there is a whole 
chapter about interpolation on Scilab's manual:
http://www.scilab.org/product/man/section_64fa3f01fdb19353faf0c6806a64a533.html

According to your code you are performing linear interpolation. I think 
that the function you are looking for is linear_interpn (see
http://www.scilab.org/product/man/linear_interpn.html). There are some 
examples on the help page (I think that the equivalent for meshgrid is 
ndgrid).

> Here is a bit of my code:
>
> [XI YI]= meshgrid(min(x):Spacing:max(x),min(y):Spacing:max(y));
>
> for i= 1:3
>
> data(:,:,i) = griddata(x,y,Hyd(:,3+i), XI, YI);
>
> end
>
> Hyd is an array with 6 data columns: (ID, x, y, z, v, d). The variables
> x and y were read out of Hyd previously.
>
In Scilab/Matlab syntax Hyd(:,3+i) is the (3+i)th column of Hyd. 
Therefore you are interpolating columns 4 (z), 5 (v) and 6 (d).

> I’m guessing that the ‘data’ variable ends up as a multi-dimensional
> array each containing x, y, and one of z, v and d. Is there a way to do
> this in Scilab?
Yes! Scilab handles multi-dimensional arrays (hypermatrices) with the 
same syntax. See 'help hypermat'.
I guess that something like
for i= 1:3
   data(:,:,i) = linear_interpn(XI, YI, x, y, Hyd(:,3+i)); // Order of 
arg. is different
end
should work (no warranty)...

Hope that helps,
Mathieu



More information about the users mailing list