画出两个向量的曲线,并将它们重叠在一起。这样可以清楚地看到两个向量之间的差异
x = linspace(0,2*pi,100);
y1 = sin(x);
y2 = cos(x);
plot(x,y1,x,y2)
legend('sin(x)','cos(x)')
构造两个向量的差异向量,用stem函数绘制差异向量的高度
x = linspace(0,2*pi,100);
y1 = sin(x);
y2 = cos(x);
diff = y1 - y2;
plot(x,y1,x,y2);
hold on;
stem(x,diff);
legend('sin(x)','cos(x)','difference');
绘制差异向量的条形图
x = linspace(0,2*pi,100);
y1 = sin(x);
y2 = cos(x);
diff = y1 - y2;
plot(x,y1,x,y2);
hold on;
bar(x,diff);
legend('sin(x)','cos(x)','difference');
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有