首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >图最小二乘法

图最小二乘法
EN

Stack Overflow用户
提问于 2021-06-24 23:46:19
回答 1查看 27关注 0票数 0

这是我用最小二乘法绘制的回归线的倍频程曲线图。

有没有办法添加类似于小箭头或线的方法来将点与实际线连接起来?这里有一个我希望它看起来是什么样子的例子。谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-25 01:28:17

我不认为有一个特定的函数来绘制残差,但手动完成它是相当简单的:

代码语言:javascript
复制
% Let's assume this is our model, predicting y from x
  model = @sin;

% Define the x domain, which will be used for plotting
  xdomain = 0:0.1:10;

% Define some (x,y) input points
  xpoints = 10 * rand(1, 10);
  ypoints = model(xpoints) + 0.5 * randn(size(xpoints));

% Plot model
  plot( xdomain, model(xdomain), 'k-', 'linewidth', 1.5 );
  hold on;

% Plot input points
  plot( xpoints, ypoints, 'ko', 'markersize', 8, 'markeredgecolor', 'k', 'markerfacecolor', [0.4,0.4,0.4], 'linewidth', 1.5 )

% Plot residual lines
  plot( [xpoints;xpoints], [model(xpoints);ypoints], 'k:', 'linewidth', 1.5 )
  hold off;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68118918

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档