Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have got a file with field values (RF simulation of a resonator) which consists of 3 columns: X and Y cartesian coordinates and the field value E(X, Y) with 9500 rows.

The problem is that my external field simulation software is not able to print the required field on a regular mesh (polar or cartesian map) as shown below:

  -15.00000      -26.00000   345000.00000 
   15.00000      -26.00000   361000.00000 
   12.20000      -27.40000   490000.00000 
  -12.20000      -27.40000   583000.00000 
   -9.27000      -28.50000  1050000.00000 
    9.27000      -28.50000  1140000.00000 
   16.50000      -28.60000   436000.00000 
  -16.50000      -28.60000   491000.00000 
    6.24000      -29.30000  1520000.00000 
   -6.24000      -29.30000  1730000.00000 
    3.14000      -29.80000  2110000.00000 

My goal is to create from the data above an interpolated surface from which I could generate a nice field matrix with a certain resolution.

My first idea was to use Gnuplot for this job so the scatter plot looks like this:

enter image description here

..and then interpolation of the field points on a regular grid like this:

enter image description here

However, Gnuplot is great but it cannot write this interpolated field back into a file for further post processing.

Now I am trying to apply the same procedure in Mathematica (ver 9) For this, I wrote the following simple commands:

stream = OpenRead["~/efields/em.dat"];

data = ReadList[stream, {Number, Number, Number}];

f = Interpolation[data];

ListPointPlot3D[{x, y, f[x, y]}, 
  {x, Min[data[[All, 1]]], Max[data[[All, 1]]]}, 
  {y, Min[data[[All, 2]]], Max[data[[All, 2]]]}] 

Unfortunately this did not work and Mathematica returned with 2 error messages:

Interpolation::udeg: Interpolation on unstructured grids is currently only supported for InterpolationOrder->1 or InterpolationOrder->All. Order will be reduced to 1. >>
ListPointPlot3D::nonopt: "Options expected (instead of {y,-480.,-26.}) beyond position 1 in *

Can anybody provide some support hints on this issue. Lets start with the basic:

  1. How to plot the data correctly as scatter plot ?
  2. How to create a surface from the randomly distributed field values ?
share|improve this question
1  
Can you post or link your data "~/efields/em.dat" –  Junho Lee Aug 13 at 4:53
    
Link to the data from a deleted answer: dl.dropboxusercontent.com/u/47218763/em.dat –  rm -rf Aug 13 at 17:06

1 Answer 1

First of all read a help. It's say:

Interpolation[{{{x1, y1, ...}, f1}, {{x2, y2, ...}, f2}, ...}] constructs an interpolation function of multidimensional data.

Your data have form {{x1, y1, f1}, {x2, y2, f3}, ...}. We need to change structure of data and then intepolate it

f = Interpolation[lst /. {x_, y_, z_} :> {{x, y}, z}, InterpolationOrder -> All]

After this you may use this function in your need. For plot:

Plot3D[f[x, y], {x, Min[lst[[All, 1]]], Max[lst[[All, 1]]]}, {y, Min[lst[[All, 2]]], Max[lst[[All, 2]]]}]

enter image description here

Or extract interpolated data:

Flatten[Table[{x, y, f[x, y]}, {x, Min[lst[[All, 1]]], Max[lst[[All, 1]]]}, {y, Min[lst[[All, 2]]], Max[lst[[All, 2]]]}], 1]
share|improve this answer
1  
In version 10 you could also use Plot3D[f[x, y], {x, y} ∈ Rectangle @@ Transpose @ f["Domain"]] –  Simon Woods Aug 13 at 11:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.