【问题标题】:Matlab: A plot with ksdensity to have a pseudo 3D lookMatlab:具有 ksdensity 的绘图具有伪 3D 外观
【发布时间】: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 绘图非常拥挤。我正在尝试将它们沿第三轴隔开,以便更好地观察它们。

【问题讨论】:

    标签: matlab 3d histogram


    【解决方案1】:

    这是您问题的明确解决方案:

    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)
    

    【讨论】:

    • 对不起,如果这令人困惑。但是,您完全理解我在图(1)中的意思。我不明白如何读取我的数据 my to x(i,:) 虽然。到目前为止,这就是我所拥有的......下面是我的 2D 绘图图片: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
    • 你从哪里得到 tmp_?
    • 那是我的数据的批次名称。 tmp_1 到 tmp_15
    • 我可以访问数据吗?它在任何地方都可用吗?
    • 是的,我将它上传到了Dropbox 文件夹。
    猜你喜欢
    • 1970-01-01
    • 2014-05-26
    • 2018-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-09
    相关资源
    最近更新 更多