Re: Intepolation of an array with missing points
- To: mathgroup at smc.vnet.net
- Subject: [mg62330] Re: Intepolation of an array with missing points
- From: Peter Pein <petsie at dordos.net>
- Date: Mon, 21 Nov 2005 03:54:14 -0500 (EST)
- References: <dlp393$1jt$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
dkjk at bigpond.net.au schrieb: > Hi, > > I have an array representing the heights of a surface over the x-y > plane. Unfortunately, the heights at several points are unknown so have > been replaced by empty strings. For an example, see > > http://users.bigpond.net.au/jdstokes/output.csv > > arr = Import["output.csv"] // MatrixForm > > My ultimate goal is to create an interpolating function of this data > which will allow me to produce a contour plot. As a very inexperienced > user of Mathematica, my initial thoughts have been someting like this: > > 1. Convert arr to an list of 3-tuples, ignoring the empty entries. (not > sure how to do this) > 2. Use Interpolation to create an InterpolatingFunction which can be > plotted in ContourPlot. > > Does anyone know of a simple method to achieve 1. and whether or not 2. > will work in this case? > > Thanks. > > James > In[1]:= arr = Import["output.csv"]; arr2 = DeleteCases[ Flatten[MapIndexed[Append[#2, #1]& , arr, {-1}], 1], {__, ""}, 1]; f[x_, y_] = Piecewise[ {{Fit[arr2, Union @@ Outer[Times, Sequence @@ (#1^Range[0, 3] & ) /@ {x, y}], {x, y}], x < y}}, 0] Out[3]= Piecewise[ {{-1.3341367980433736 + 0.37569996824773316*x - <snip>...</snip> + 0.00005871778448916324*x^2*y^3 - 1.2514663657939389*^-6*x^3*y^3, x < y}}] And now you can do a ContourPlot[f[Length[arr] - y, x], {x, 1, Length[arr[[1]]]}, {y, 1, Length[arr]}] Regards, Peter