【问题标题】:Plotting cdf and regular graph in same axis in matlab在matlab中的同一轴上绘制cdf和正则图
【发布时间】:2014-09-26 20:30:03
【问题描述】:

我有一个包含 1000 个随机数的向量,称为 v。我还有一个向量,称为 x,它表示生成 v 中数字的域,另一个向量 y 具有中值的 cdf 的数字v. 我知道我可以做 plot(x,y);并获得(非经验)cdf 的平滑函数,我也知道我可以做 cdfplot(v) 来获得经验 cdf 的函数。

我的问题是:我怎样才能在同一组轴上获得这些图? 感谢您的帮助。

【问题讨论】:

  • 尝试使用hold函数(link)

标签: matlab math


【解决方案1】:

您可以使用 ecdf 为经验 cdf 图生成数据,也可以像您提到的那样直接使用 cdfplot 绘制它。我建议使用cdfplot,因为它设置了更多的东西,比如网格:

hFig = figure;
cdfplot(v);
hold all;
plot(x, y);

作为奖励!考虑以对数单位显示 X 轴,以最适合您的数据为准:

hAxes = get(hFig, 'CurrentAxes'); 
set(hAxes, 'XScale', 'log')

【讨论】:

    猜你喜欢
    • 2015-09-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多