【发布时间】:2013-09-21 05:43:50
【问题描述】:
我用过这段代码:
private void ilPanel1_Load(object sender, EventArgs e)
{ using (ILScope.Enter())
{
ILArray<float> X = new float[] { 0, 0, 1, 1, 2.5F, -2.6F, 5, 9, 1, 38 };
ILArray<float> Y = new float[] { 1, 0, 1, 0, 1.5F, 0.5F, 5, 9, 1, 39 };
ILArray<float> Z = new float[] { 0, 0, 1, 1, 0.4F, -0.2F, 5, 9, 1, 39 };
X = X.Reshape(2,5);
Y = Y.Reshape(2,5);
Z = Z.Reshape(2,5);
ilPanel1.Scene.Add(new ILPlotCube(twoDMode: false) {
new ILSurface(Z, colormap: Colormaps.Cool) {
Colors = 1.4f ,Children = { new ILColorbar() }
}
});
}
}
这会产生:
但是我检查了this question 并尝试修改已弃用的ILnumerics solution(因为我没有找到其他c#代码),但仍然没有得到它,每个坐标(Z、X 和 Y)对应一个切片(m x n ) 在数组中。所以有必要重塑数据。
这部分是问题:
X = X.Reshape(2,5);
Y = Y.Reshape(2,5);
Z = Z.Reshape(2,5);
如果我没有给出正确的大小,程序就会失败,所以在例子中我每个向量上有 10 个元素,所以当我重新分析时,我会把 2,5 乘以 10?...
如果我有 11 个元素,如果我将 2,5 放在 reshape 上会出错?
怎么办?
我尝试过使用X = X.Reshape(11);,但它失败了……如果我使用X = X.Reshape(10);,它就不会画任何东西
【问题讨论】:
标签: c# plot ilnumerics