且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何创建3D关节密度图MATLAB?

更新时间:2023-11-17 15:13:16

在mathworks论坛的一个人的帮助下,这是我最终获得的绝佳解决方案:

With help from a guy at mathworks forum, this is the great solution I ended up with:

(data_x和data_y是要在hist3上计算的值)

(data_x and data_y are values, which you want to calculate at hist3)

x = min_x:step:max_x; % axis x, which you want to see
y = min_y:step:max_y; % axis y, which you want to see

[X,Y] = meshgrid(x,y); *%important for "surf" - makes defined grid*

pdf = hist3([data_x , data_y],{x y}); %standard hist3 (calculated for yours axis)
pdf_normalize = (pdf'./length(data_x)); %normalization means devide it by length of 
                                         %data_x (or data_y)
figure()
surf(X,Y,pdf_normalize) % plot distribution

这给了我3D的关节密度图.可以通过以下方法计算表面上的积分来检查:

This gave me the joint density plot in 3D. Which can be checked by calculating the integral over the surface with:

integralOverDensityPlot = sum(trapz(pdf_normalize));

当变量 step 变为零时,变量 integralOverDensityPlot 变为1.0

When the variable step goes to zero the variable integralOverDensityPlot goes to 1.0

希望这对某人有所帮助!

Hope this help someone!