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

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

发布于 2021-06-25 01:28:17
我不认为有一个特定的函数来绘制残差,但手动完成它是相当简单的:
% 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;
https://stackoverflow.com/questions/68118918
复制相似问题