我在图形上有1000多个数据点。我想每隔100个点数据点绘制一些误差线。
x = 1:1500:1100;
y = [1:1200];
err = ?
plot(x.y);
hold on;
errorbar(x,y,err);
我需要'err'的什么值,所以我只会得到10条误差线?
正如David在his comment中指出的那样,您的代码不是正确的MATLAB代码。不过,我认为您对MATLAB有足够的了解:基本上,您需要为x
设置单独的y
和errorbar
值以及应绘制的实际误差err
。然后,您可以使用适当的errorbar
命令。
让我们看一下这个小例子:
errorbar
您将得到这样的输出:
x = -5:0.1:5;
y = sin(x);
xErr = linspace(-5, 5, 11); % Specify x locations for errorbar plot
yErr = sin(xErr); % The y values at these x locations
err = rand(1, 11); % The actual errors, here: some random values
plot(x, y, 'r'); % Plot
hold on;
errorbar(xErr, yErr, err, 'o'); % Actual errorbar plot at specific x locations
hold off;
免责声明:我使用Octave 5.1.0做到了这一点,但语法应与MATLAB相同。如果不是,请报告任何错误。
希望有帮助!