数学实验与Matlab
16
set(gca,'fontsize',20) 】 4. 文字标注指令
【 plot(x,y1,'b',x,y2,'k-') ,
set(gca,'fontsize',15,'fontname','times New Roman'), %设置轴对象的字体为times
% New Roman,字体的大小为15
title(' \\it{Peroid and linear peroid function}'); %加标题,注意文字用单引号' ' 加上
%斜杠'\\'后可输入不同的设置,例如it{…}表示花括号里的文字为斜体;如果有多项设置,
%则可用\\…\\…\\…连续输入。
16
数学实验与Matlab
17
xlabel('x from 0 to 8*pi it{t}\\'); ylabel('\\it{y}'); %说明坐标轴 text(x(49),y1(50)-0.4,'\\fontsize{15}\\bullet\\leftarrowThe period function {\\itf(x)}');
%在坐标(x(49),y1(50)-0.4)处作文字说明, 各项设置用\隔开。 %\\fontsize{15}\\bullet\\leftarrow的意义依次是:\\字体大小=15 \\ 画圆点 \\左箭头
text(x(14),y2(50)+1,'\\fontsize{15}The linear period function {\\itg(x)}\\rightarrow
\\bullet') %与上一语句类似,用右箭头 】
17
数学实验与Matlab
6543210 Peroid and linear peroid function18
◆观察指令legend和num2str的用法:在同一张图上画出
, 这里y?sin(t)和y?3e图2.5 文字标注 t?[0,3?], 并进行适当的
标注。
zxy2_2.m
The linear period function g(x)?·y·? The period function f(x)?0.5t-1051015x202530 【 clf,
t=0:0.1:3*pi;alpha=0:0.1:3*pi; plot(t,sin(t),'r-');hold on;
plot(alpha,3*exp(-0.5*alpha),'k:');
set(gca,'fontsize',15,'fontname','times New Roman'),
18
数学实验与Matlab
19
xlabel('\\it{t(deg)}');ylabel('\\it{magnitude}');
title(' \\it{sine wave and {\\it{Ae}}^{-\\alpha{\\itt}}wave}'); %注意\\alpha的意义
text(6,sin(6),'\\fontsize{15}The Value \\it{sin(t)} at
{\\itt}=6\\rightarrow\\bullet', 'HorizontalAlignment','right'),
%上面的语句是一整行,如果要写成两行,必须使用续行号 ? ,例如要在“ bullet',”
%后换行,需写“bullet', ?”后才能换行。
19
数学实验与Matlab
20
% 'HorizontalAlignment','right' 表示箭头所指的曲线对象在 文字的右边。
text(2,3*exp(-0.5*2),['\\fontsize{15}\\bullet\\leftarrow The Value of \\it{3e}^{-0.5
\\it{t}}=',num2str(3*exp(-0.5*2)),' at \\it{t} =2 ']);
%num2str的用法:
['string1' ,num2str,'string2'],注意方括号的使用。
%legend('\\itsin(t)','{\\itAe}^{-\\alphat}') % 请结合图形观察此命令的使用 】 运行结果如图2.6所示。
20