【问题标题】:Matlab plot regression functionMatlab绘图回归函数
【发布时间】:2013-09-17 04:30:54
【问题描述】:

我正在以这种方式使用 MATLAB 函数 plotregression 绘制线性回归:

hand = plotregression(x, y, 'Regression')

但是,我想去掉图中的y = T 线,并使用不同的标记,例如*。我怎样才能做到这一点?我已经尝试过set(hand, ..,),但没有成功。

【问题讨论】:

  • 我不确定是否可以使用plotregression,但作为一种解决方法,您可以将polyfitpolyval 结合使用,如建议的here
  • 是的,polyfit 和 polyval 非常适合我的目的。谢谢!

标签: matlab linear-regression


【解决方案1】:

plotregression 函数将句柄返回到图形。此图有 3 个子项:图例、轴和 uicontrol。对于简单的调用,uicontrol 是不可见的。该轴也有 3 个孩子:data、fit、y = T。要获得您想要的,我们需要删除第二个孩子的第三个孩子并更改第二个孩子的第一个孩子的标记。然后我们需要重新生成图例,因为它不会动态更新。

x = 1:10;
y = randn(1, 10);
hand = plotregression(x, y, 'Regression');
h = get(hand, 'Children');
hh = get(h(2), 'Children');
delete(hh(3))
set(hh(1), 'Marker', '*')
legend('Data', 'Fit', 'Location', 'NorthWest');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-07
    • 2018-04-10
    相关资源
    最近更新 更多