我在matlab中遇到了问题。
我在deltaX的向量上使用了ksdensity函数,这是我的计算X减去实际X. 我在deltaY上做了同样的事情。
然后我在那些数据上使用了情节。这给了我两个2d图。
因为我有两个图表显示我的系统在计算X和Y时是否准确(如同高斯贝尔那样)。现在我想有一个情节,但在3d。 代码就是这样:
[f,xi] = ksdensity(deltaX);
figure;
plot(xi,f)
答案 0 :(得分:0)
Ok what I'm about to show is probably not the correct way to visualize your problem, mostly because I'm not quite sure I understand what you're up to. But this will show you an example of how to make the Z matrix as discussed in the comments to your question.
Here's the code:
x = wgn(1000,1,5);%create x and y variables, just noise
y = wgn(1000,1,10);
[f,xi] = ksdensity(x);%compute the ksdensity (no idea if this makes real-world sense)
[f2,xi2] = ksdensity(y);
%create the Z matrix by adding together the densities at each x,y pair
%I doubt this makes real-world sense
for z=1:length(xi)
for zz = 1:length(xi2)
Z(z,zz) = f(z)+f2(zz);
end
end
figure(1)
mesh(xi,xi2,Z)
Here's the result:
I leave it up to you to determine the correct way to visualize your density functions in 3D, this is just how you could make the Z matrix. In short, the Z matrix contains the plot elevation at each x,y coordinate. Hope this helps a little.