C# 曲面图参数

C# 曲面图参数,c#,3d,matplotlib,plot,ilnumerics,C#,3d,Matplotlib,Plot,Ilnumerics,我对在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> in

我对在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(); 
float[]x=新的float[sizeX];//满是时间戳
float[]y=新的float[sizeY];//充满价值
float[,]z=新的float[sizeX,sizeY];//由[x,y]映射的值填充
ILInArray inX=ILMath.array(x);
ILInArray inY=ILMath.array(y);
ILInArray inZ=ILMath.meshgrid(inX*inY,inX,inY);
//如何用z[,]填充inZ?
ILRetArray outMesh=ILMath.meshgrid(inX,inY,inZ,null,null);
添加(新的ILSurface(outMesh,null,null,null,null));
//plotCube已附着到场景,且场景中包含ILPanel
ilPanel1.Refresh();
希望将其映射到数组中,以便可以在
ILSurface
上打印

我尝试了一些
ILMath.meshgrid
来填充
ILInArray ZXYArray
,但没有成功

希望我已经说清楚了。欢迎任何帮助


谢谢。

下面是一个简单的示例,说明如何使用ILNumerics绘制3D曲面,并提供自定义的X和Y范围。它需要使用ILNumerics定期设置Windows.Forms应用程序:

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() }
            }
        }
    };
}
private void ilPanel1\u加载(对象发送方,事件参数e){
//定义X和Y范围
ILArray X=ILMath.vec(-10.0,0.1,10.0);
ILArray Y=ILMath.vec(-6.0,0.1,6.0);
//计算每个网格点的X和Y坐标
ILArray YMat=1;//提供YMat作为meshgrid的输出
ILArray XMat=ILMath.meshgrid(X,Y,YMat);//这里只需要2D函数的网格
//为ILSurface:X X Y X 3预分配数据数组
//注意顺序:对于每个网格点的Z,X,Y坐标,每个X X X Y的3个矩阵切片
ILArray A=ILMath.zero(Y.长度,X.长度,3);
//填写Z值(用您自己的函数/数据替换它!!)
A[“:;:;0”]=ILMath.sin(XMat)*ILMath.sin(YMat)*ILMath.exp(-ILMath.abs(XMat*YMat)/5;
A[“:;:;1”]=XMat;//每个网格点的X坐标
A[“:;:;2”]=YMat;//每个网格点的Y坐标
//设置场景+打印立方体+曲面
ilPanel1.Scene=新ILScene(){
新ILPlotCube(twoDMode:false){
新表面(A){
UseLighting=true,
Children={new ILColorbar()}
}
}
};
}
它产生以下结果:

这里是同样的例子


请注意定义栅格点坐标的顺序。请参阅此处的文档:

到目前为止是否有任何源代码?预期结果?获得的结果?预期:具有一系列fft的表面被时间(x)分割,其中y(频率)和z(振幅)。已获得:仅plotCube空白。当前:我还不知道如何将[,]解析为数组。就这个话题做一些研究。这(代码)是正确的方法吗?