【发布时间】:2016-03-21 00:11:21
【问题描述】:
我想在 3D 中使用 ks 密度制作直方图。 我的情节与此处的示例相似;
http://www.mathworks.com/help/stats/fit-kernel-distributions-to-grouped-data-using-ksdensity.html
在我的示例中,我有 15 个不同的直方图,并且这个 2D 绘图非常拥挤。我正在尝试将它们沿第三轴隔开,以便更好地观察它们。
【问题讨论】:
我想在 3D 中使用 ks 密度制作直方图。 我的情节与此处的示例相似;
http://www.mathworks.com/help/stats/fit-kernel-distributions-to-grouped-data-using-ksdensity.html
在我的示例中,我有 15 个不同的直方图,并且这个 2D 绘图非常拥挤。我正在尝试将它们沿第三轴隔开,以便更好地观察它们。
【问题讨论】:
这是您问题的明确解决方案:
figure(1)
hold on; grid on
for i = 1:15
path = ['tmp_',num2str(i),'.out'];
fid = fopen(path, 'r');
a = textscan(fid,'%f');
% Appearantly the first line is a string in some of your files
% This if statement will take care of it ;)
if isempty(a{1})
fgetl(fid);
a = textscan(fid,'%f');
end
tmp = a{1};
% Some of your files (all but one I think) contain element numbering
% This if statement takes care of it ;)
if length(tmp) > 180000
tmp = tmp(2:2:end);
end
fclose(fid);
[f, xi] = ksdensity(tmp);
plot3(xi, ones(length(f))*i, f)
end
view(3)
【讨论】:
xi = linspace(80,150,100); figure(1); hold on; grid on; x = zeros(180000,15); for i = 1:15 x(i,:) = ; % unsure how to read in my data f(i,:) = ksdensity(tmp_(i).out,xi); plot3(xi, ones(length(f(i,:)),1)*i, f(i,:)) end view(3) y = 1:15;picpaste.com/pics/untitled-2QXgdcFa.1458704706.jpg