0
点赞
收藏
分享

微信扫一扫

SpringCloud2023中使用Seata解决分布式事务

1、基础绘图

MATLAB有一个强大的绘制引擎,可以生成各种各样的绘图。

d7f98b963943448cb35a792065495e26.png

1.1根据数据绘图

1、在特定范围内生成函数的数值

2、以图形方式显示数据“点”

1.1.1、plot()

例如:

plot(cos(0:pi/20:2*pi));

ca969814f2904ce79edd6a1dabbe1235.png

1.1.2、hold on / off  

Matlab在绘图时,会把旧的图形删除掉,使用hold on将两个图形绘制在一个figure中

hold on
plot(cos(0:pi/20:2*pi));
plot(sin(0:pi/20:2*pi));
hold off

5e2597bfb1cb434d9f50ab8b2724697a.png

 1.2、绘图形式

数据标识线型颜色
.-k
*--b
x-.c
+:r

更多详情可参照: 官方文档

 例如:

hold on
plot(cos(0:pi/20:2*pi),'or--');
plot(sin(0:pi/20:2*pi),'xg:');
hold off

 00e060d0ecf14d808784219e851599e9.png

 1.2.1、legend()

若我们想添加注释到图中

x=0:0.5:4*pi;
y=sin(x);h=cos(x);w=1./(1+exp(-x));
g=(1/(2*pi*2)^0.5).*exp((-1.*(x-2*pi).^2)./(2*2^2));
plot(x,y,'bd-',x,h,'gp:',x,w,'ro-',x,g,'c^-');
legend('sin(x)','cos(x)','sigmoid','gauss function');

19016f77716f4850a82dce368c40d96e.png

1.2.2、title()和label()

通过此函数我们可以为图形加上表头,横轴名称,纵轴名称等。 

x=0:0.1:2*pi;y1=sin(x);y2=exp(-x);
plot(x,y1,'--*',x,y2,':o');
xlabel('t=0 to pi/2');
ylabel('values of sin(t) and exp(-t)');
title('function plots of sin(t) and exp(-t)');
legend('sin(x)','exp(-x)');

1.2.3、text()和annotation()

x=linspace(0,3);y=x.^2.*sin(x);plot(x,y);
line([2,2],[0,2^2*sin(2)]);
str='$$ \int_{0}^{2} x^2\sin(x) dx $$';
text(0.25,2.5,str,'Interpreter','latex');
annotation('arrow','X',[0.32,0.5],'Y',[0.6,0.4]);

814aa7e475d643dab0687eecaba77ff0.png

例题:将f绘制一条黑线,将g绘制一系列红色范围在t=1到2的圆圈。

t=1:0.01:2;
f=t.^2;
g=sin(2*pi*t);
plot(t,f,'-k',t,g,'or');
xlabel('Time(ms)');
ylabel('f(t)');
title('Mini Assignment #1');
legend('t^2','sin(2\pit)');

 2、图形对象参数

2.1、Modifying properties of An Object

策略:

2.1.1、Identifying the Handle of An Object

· 在创建时:

· 实用功能:

FunctionPurpose
gcareturn the handle of the "current" axes
gcfreturn the handle of the "current" figure
allchildfind all children of specified objects
ancestorfind ancestor of graphics object
deletedelete an object
findallfind all graphics objects

2.1.2、Fetching or Modifying Properties

· 获取物件:

x=linspace(0,2*pi,1000);
y=sin(x);plot(x,y);
h=plot(x,y);
get=(h);

73f7f33adebd4b8b984ead5c33dfb0a6.png · 修改物件:

x=linspace(0,2*pi,1000);
y=sin(x);plot(x,y);
h=plot(x,y);
get=(h);
set(gca,'XLim',[0,2*pi]);
set(gca,'YLim',[-1.2,1.2]);
%setting fond and tick of axes
set(gca,'FontSize',25);
set(gca,'XTick',0:pi/2:2*pi);
set(gca,'XTickLabel',0:90:360)
set(gca,'XTickLabel',{'0','\pi/2','\pi','3\pi/2','2\pi'})

2.1.3、Line Specification

 · 线的类型和宽度:

 2.1.4、Marker Specification

· 标记的面部和边缘颜色:

x=rand(20,1);set(gca,'FontSize',18);
plot(x,'-md','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','g','MarkerSize',10);
xlim([1,20])

01618cf7d41e429c8363be2c16ad79bc.png

2.2、Multiple Figures 

· 通过调用figure创建一个窗口:

x=-10:0.1:10;
y1=x.^2-8;
y2=exp(x);
figure,plot(x,y1);
figure,plot(x,y2)

 2.2.1、指定Figures的位置和大小:

2.2.2、在一个figure中创建多个小figure:

t=0:0.1:2*pi;
x=3*cos(t);y=sin(t);
subplot(2,2,1);plot(x,y);axis normal
subplot(2,2,2);plot(x,y);axis square
subplot(2,2,3);plot(x,y);axis equal
subplot(2,2,4);plot(x,y);axis equal tight;
grid on%打开网格线

 2.3、保存图像到文件

 

举报

相关推荐

0 条评论