2013-11-03 82 views
2

我被繪製在繪製ILSurface中的曲面上。 的場景是以下內容:ILSurface繪圖參數

劇情不規則柵格:

float[] x = new float[sizeX]; // filled with timestamps 

float[] y = new float[sizeY]; // filled with values 

float[,] z = new float[sizeX, sizeY]; // filled with values mapped by [x,y] 

ILInArray<float> inX = ILMath.array(x); 
ILInArray<float> inY = ILMath.array(y); 
ILInArray<float> inZ = ILMath.meshgrid(inX * inY, inX, inY); 

// how do i fill the inZ with z[,]? 

ILRetArray<float> outMesh = ILMath.meshgrid(inX, inY, inZ, null, null); 

plotCube.Add(new ILSurface(outMesh, null, null, null, null)); 

// plotCube already attached to the scene, and the scene with the ILPanel 

ilPanel1.Refresh(); 

想要一個陣列中的這種映射,因此它可以是在一個ILSurface曲線圖。

我試了一些ILMath.meshgrid填補ILInArray<double> ZXYArray沒有成功。

希望我已經清楚。任何幫助歡迎。

謝謝。

+0

到目前爲止的任何源代碼?預期結果?獲得的結果? –

+0

預期:一系列fft被時間(x)分解的曲面,其中y(頻率)和z(振幅)。獲得:只是plotCube空白。目前:我不知道如何解析[,]到ILInArray呢。對這個話題做一些研究。那(代碼)是正確的嗎? – plac88

回答

1

下面介紹一個簡單的例子,說明如何使用ILNumerics繪製3D曲面,並提供自定義的X和Y範圍。它需要一個Windows.Forms的應用與ILNumerics常規設置:

private void ilPanel1_Load(object sender, EventArgs e) { 
    // define X and Y range 
    ILArray<float> X = ILMath.vec<float>(-10.0, 0.1, 10.0); 
    ILArray<float> Y = ILMath.vec<float>(-6.0, 0.1, 6.0); 

    // compute X and Y coordinates for every grid point 
    ILArray<float> YMat = 1; // provide YMat as output to meshgrid 
    ILArray<float> XMat = ILMath.meshgrid(X, Y, YMat); // only need mesh for 2D function here 

    // preallocate data array for ILSurface: X by Y by 3 
    // Note the order: 3 matrix slices of X by Y each, for Z,X,Y coordinates of every grid point 
    ILArray<float> A = ILMath.zeros<float>(Y.Length, X.Length, 3); 

    // fill in Z values (replace this with your own function/data!!) 
    A[":;:;0"] = ILMath.sin(XMat) * ILMath.sin(YMat) * ILMath.exp(-ILMath.abs(XMat * YMat)/5); 
    A[":;:;1"] = XMat; // X coordinates for every grid point 
    A[":;:;2"] = YMat; // Y coordinates for every grid point 

    // setup the scene + plot cube + surface 
    ilPanel1.Scene = new ILScene() { 
     new ILPlotCube(twoDMode: false) { 
      new ILSurface(A) { 
       UseLighting = true, 
       Children = { new ILColorbar() } 
      } 
     } 
    }; 
} 

它產生以下結果:

ILNumerics Surface Plot

這裏是相同的例子as interactive Web Component

注意網格點座標定義的順序。看到這裏的文檔:http://ilnumerics.net/surface-plots.html