簡體   English   中英

Matlab:具有ksdensity的圖以具有偽3D外觀

[英]Matlab: A plot with ksdensity to have a pseudo 3D look

我想在3D中使用ksdensity制作直方圖。 我的情節看起來與這里的示例相似。

http://www.mathworks.com/help/stats/fit-kernel-distributions-to-grouped-data-using-ksdensity.html

在我的示例中,我有15個不同的直方圖,而此二維圖非常擁擠。 我正在嘗試沿着第3軸將它們隔開,以便可以更好地觀察它們。

這是您的問題的顯式解決方案:

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM