前言
主要介绍3种画竖线图的方法,使用工具为MATLAB 2020a。
第一种1
x = 1:3;
y = [1,5,6]; %5为在2点的y值
n = length(x);
for i = 1:n
plot([x(i),x(i)],[0,y(i)],'b');
hold on
end
xlim([0 5])
运行结果:
第二种2
x = 1:3;
y=[1,5,6]; %5为在2点的y值
stem(x,y,'Marker','none');
xlim([0 5])
运行结果:
第三种
x = 1:3;
y = [1,5,6]; %5为在2点的y值
n = length(x);
for i = 1:n
line([x(i),x(i)], [0,y(i)], 'color', 'b')
hold on
end
xlim([0 5])
总结
本文内容主要介绍了3种利用MATLAB画不带标记竖线图的方法,参考资料见文章末尾。