[英]Matlab 3D surface normal distribution
I have two normal distributions and i am trying to make a volumetric surface from them. 我有两个正态分布,我正试图从它们构成一个体积表面。 I got the following graph 我得到以下图
clear; clc;
nsamp = 100000;
%
% Basic variables
%
m1=2.724;
dp1=0.375;
R = normrnd(m1,dp1, nsamp, 1);
m2=1.345;
dp2=0.135;
S = normrnd(m2,dp2, nsamp, 1);
%
Z = R - S;
I = (Z < 0);
pf = sum(I)/nsamp
beta = -norminv(pf)
%
% Histograms
hist(S,20)
hold on
hist(R,40)
set(findobj('Type','patch'),'Facecolor','none','Edgecolor','black')
set(gca,'Fontsize',18,'Fontname','euclid')
xlabel('R & S')
figure
scatterhist(R,S)
xlabel('R'),ylabel('S')
and i would like to make a 3D surface and the points in red to remain in red and the blue points in blue. 我想制作一个3D曲面,将红色的点保留为红色,将蓝色的点保留为蓝色。 Can someone help me? 有人能帮我吗? Regards 问候
I can't write a tested solution right now - not access to Matlab license server. 我现在无法编写经过测试的解决方案-无法访问Matlab许可证服务器。 But you have two problems here. 但是您这里有两个问题。
The first is to create a surface plot of density. 首先是创建密度的表面图。 You can use the hist3
function for the this - and if you return the values of the bins you can control the plotting yourself: 您可以为此使用hist3
函数-如果返回bin的值,则可以自己控制绘图:
[NC] = histc(X) [NC] = histc(X)
(I'm sorry it is not clear to me what you really want to plot - is it R
, S
, Z
, or R+S
? that's why I used X
). (很抱歉,我不清楚您真正想绘制什么-是R
, S
, Z
还是R+S
?这就是为什么我使用X
)。
Then to color the graph, you can use patch coloring - see http://www.mathworks.com/help/matlab/visualize/specifying-patch-coloring.html for how to do that. 然后,要给图形着色,可以使用补丁着色-有关操作方法,请参见http://www.mathworks.com/help/matlab/visualize/specifying-patch-coloring.html 。
The combination of these two should get you a long way there... but it's still a little unclear what you really want to do. 这两种方法的结合应该可以使您走得很远……但是仍然不清楚您真正想做什么。 I hope these hints help you on your way. 希望这些提示对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.