matlab 绘制曲线

tech2025-06-13  2

添加图形标注 title函数 给图形添加标题 添加一行标题 title(’…’),若是需要添加两行,则是title({’’,’’}) 若图形标题中使用Latex格式控制符 则需要用大括号括起来,title(‘y=cos{\omega}t’) title(‘y=e^{axt}’) y = e的ax次方 title(‘X_{1}{\geq}X_(2)’) x1大于等于x2 title(’{\bf y=cos{\omega}t+{\beta}}’) y=coswt+beta 这里的bf是加粗的含义 \it斜体 \rm正体

title(图形标题,属性名,属性值) color属性:文本颜色 FontSize:字号

xlabel函数和ylabel函数 xlabel(‘-2\pi\leq x \leq 2\pi’)

text和gtext函数 text(x,y说明) gtext(说明) 例如text(-2*pi,0,’-2{\pi}’) 表示(-2pi,0)这个点标注-2pi text(3,0.28,’\leftarrow sin(x)’)左箭头

legend函数 x=linspace(0,2pi,100) plot(x,[sin(x);sin(2x);sin(3*x)]) legend(‘sin(x)’,‘sin(2x)’,‘sin(3x)’)

坐标控制 (1)axis函数 axis([xmin,xmax,ymin,ymax,zmin,zmax]),例如axis([-pi,pi,-4,4])就是。。。。 axis其他用法:axis equal横纵坐标轴采用等长刻度 on 显示坐标轴,off不显示,square正方形坐标系,auto使用默认设置

(2)给坐标系加网格和边框 gird on显示(网格) gird off不显示 grid切换模式

box on(边框) box off box

(3)图形保持 hold on 保持图形 hold off 不保持图形 hold切换

(4)图形窗口的分割 subplot函数 subplot(m,n,p),其中m和n指定将图形窗口分成mxn个绘图区,p指定当前活动区域 subplot(2,2,1); x = linspace(0,2pi,60); y = sin(x); plot(x,y); title(‘sin(x)’); axis([0,2pi,-1,1]); 注意这里subplot 要放在上面写

最新回复(0)