一、
代码:
function example_curve_plot
clc;close all;
t=0:0.01:5;
x=sin(2*pi*t).^3;
% 1图像
h_f=figure(1);
set(h_f,'position',[50,100,600,350]);
% 2图线
h_p=plot(t,x);
set(h_p,'color','b','linestyle','-','linewidth',2);
% 3坐标
h_a=gca;
% 31坐标范围
set(h_a,'xlim',[0,5],'ylim',[-1.45,1.45]) % 31坐标范围
% 32网格线
set(h_a,'xgrid','on','ygrid','on','gridlinestyle','-','gridcolor',[0.15,0.15,0.15],'gridalpha',0.25) %32网格线
% 33坐标标签
xlabel('$Times(t)$','Interpreter','latex') % 33坐标标签
ylabel('$Displacement(mm)$','Interpreter','latex')
set(h_a,'fontname','times new roman','fontsize',16,'fontweight','bold')
% 4图例
h_l=legend('$x(t)$');
set(h_l,'interpreter','latex','fontname','times new roman','fontsize',16)
set(h_l,'location','southeast','color','none','edgecolor','none')
% 5文本
h_t=text(0.1,1.25,'$x = \sin \left( {2\pi t} \right)$');
set(h_t,'interpreter', 'latex','fontname','times new roman','fontsize',16);
end
结果:
二、
代码:
function example_curve_plot2
clc
omega=[0.1:0.01:10];
H=abs(1./(-omega.^2 + 1 +0.2*1i));
% 1图像
h_f=figure(2);
set(h_f,'position',[50,100,600,350]);
% 2图线
h_p=plot(omega,H);
set(h_p,'color','b','linestyle','-','linewidth',2);
% 3坐标
h_a=gca;
%坐标范围
set(h_a,'xlim',[0.1,10],'ylim',[0.001,10],'yscale','log');
%网格
set(h_a,'xgrid','on','ygrid','on','gridlinestyle','-','GridColor',[0.15,0.15,0.15],'gridalpha',0.25);
%标签
xlabel('$w\omega$','Interpreter','latex');
ylabel('$H\left( w \right)$','Interpreter','latex');
set(h_a,'fontname','times new roman','fontsize',16,'fontweight','bold');
% 4图例
% 5文本
h_t=text(2.5,5,'$H = ||\frac{1}{{ - {w^2} + 1 + 0.02j}}||$','interpreter','latex');
set(h_t,'fontname','times new roman','fontsize',16);
end
结果: