How should I format my .dat file so that a 3D vector plot can be made?

前端 未结 1 1493
猫巷女王i
猫巷女王i 2021-02-06 08:23

I\'m working this programming task for college where we have to write a c++ program that calculates the magnetic field vector for certain coils in 3D space.

<
相关标签:
1条回答
  • 2021-02-06 08:42

    I made this simple example to show you how to draw a vector field. The output would be something like this pic:

    enter image description here

    The data example I used to plot this was:

    # Px    Py    Pz    Bx    By    Bz
      0     0     0     0.8   0.8   0.45
      0     0     1     0.5   0.7   0.35
      0     0     2     0.7   0.5   0.25
      0     1     0     0.65   0.65   0.50
      0     1     1     0.6   0.6   0.3
      0     1     2     0.45   0.45   0.20
      1     0     0     0.5   0.7   0.35
      1     0     1     0.75   0.75   0.4
      1     0     2     0.85   0.85   0.25
      1     1     0     0.90   0.85   0.23
      1     1     1     0.95   0.86   0.20
      1     1     2     0.98   0.88   0.13
      2     0     0     0.73   0.83   0.43
      2     0     1     0.53   0.73   0.33
      2     0     2     0.73   0.53   0.23
      2     1     0     0.68   0.68   0.52
      2     1     1     0.63   0.57   0.23
      2     1     2     0.48   0.42   0.22
    

    The command to plot it is:

    gnuplot> splot "./data3d.dat" with vectors
    

    Now you should read the section 44, page 53 of the official manual (and here the pdf). You may find this site also very useful.

    Edited:

    This command doesn't fit into your description: mapping from (x,y,z) to (t,u,v). It actually does this mapping: from (X,Y,Z) to (X+dX,Y+dY,Z+dZ).

    Cheers, Beco

    0 讨论(0)
提交回复
热议问题