在特定范围内矢量的MATLAB绘图 [英] MATLAB plot of a vector on a specific range
本文介绍了在特定范围内矢量的MATLAB绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要知道如何在特定间隔内绘制矢量? 我用它通过绘制具有不同颜色的矢量值来突出显示此间隔. 因此,最终,我将需要首先绘制矢量,例如使用蓝色绘制,然后再使用红色绘制该特定间隔. 谢谢你的时间, 问候
I need to know how can i plot a vector over a specific interval? I'm using that to highlight this interval, by plotting the vector values with a different color. So Eventually, i will need to plot the vector as it is first with blue color for example, and then plot that specific interval with red color. Thanks for your time, Regards
推荐答案
t = 0:0.01:8*pi;
y = sin(t);
如果要用红色绘制特定的t
间隔,则:
If you want to plot a specific t
interval in red then:
ind = t>2 & t<6;
plot(t,y);
hold on
plot(t(ind), y(ind), 'r')
如果要用红色绘制特定的y
间隔,则:
If you want to plot a specific y
interval in red then:
ind = y>0.5 & y<0.8;
plot(t,y);
hold on
plot(t(ind), y(ind), 'r')
这篇关于在特定范围内矢量的MATLAB绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文