博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Matlab_Graphics(1)_2D
阅读量:5140 次
发布时间:2019-06-13

本文共 2864 字,大约阅读时间需要 9 分钟。

1.Add title ,axis Lables, and Legend to Graph:

1 x=linspace(-2*pi,2pi,100);2 y1=sin(x);3 y2=cos(x);4 figure5 plot(x,y1,x,y2);6 title('Graph of sine and cosine between -2\pi and 2\pi');% to display Greek symbols in a title,use the tex markup '\'7 xlabel('-2\pi
<2\pi'); % x-axis label8 ylabel('sine and cosine value');% y-axis label9 legend('y=sin(x)','y=cos(x)'); % add legend

2.change Graph axis Limits functions:

  Axis function: Axis([xmin,xmax,ymin,ymax]); or xlim([xmin,xmax])/ylim([ymin,ymax])/zlim([zmin,zmax])

3.Change Tick Marks and Tick Labels of Graph:

x=linspace(-10,10,200);y=cos(x);figureplot(x,y)h=gca; % Use gca to get the handle for the current axesh.XTick=[-3*pi,-2*pi,-pi,0,pi,2*pi,3*pi];h.YTick=[-1,-0.5,0,0,5,1]; % Change the location of the tick marks on the plot                                        % by setting the XTick and YTick properties of the                                        % axes.h.XTickLabel={
'-3pi','-2pi','-pi','0','pi','2pi','3pi'};h.YTickLabel={
'min=1','-0.5','0','0.5','max=1'};

Specify tick mark labels by setting the XTickLabel and YTickLabel porperties of the axes, Set these properties using

a cell array of string with the desired labels .If you do not specify enough text labels for all the tick marks,then

MATLAB cycles through the labels.

4. grid on : to display the major grid lines, The grid on command sets the XGrid,YGrid,and ZGrid axes prperties.

5. grid minor: to display the minor grid lines,The grid minor command sets the XMinorGrid/YMinorGrid, and ZMinorGrid properties.

6. grid off : to remove the grid lines,

7.Display Grid Lines in Single Direction:

x=-10:10;y=x.^2;figureplot(x, y);ax=gca;ax.XGrid='on'; % setting the XGrid axes property to 'on ' and the YGrid axes property to 'off'ax.YGrid='off';ax.XMinorGrid='on'; % setting the XGridMinor axes property to 'on ' and the YGridMinor axes ax.YMinorGrid='off'; % property to 'off'

 8.Change Grid Line Style:

x=-10:10y=x.^2;figureplot(x,y)grid ongrid minorax=gca;ax.GridLineStyle='-';         %change the grid line style using the GridLineStyle and ax.MinorGridLineStyle='-'; %MinorGridLineStyle axes properties.

9.hold on: retain the line plot and add a new plot to the graph.

10.hold off: to reset the hold state so that new plots replace existing plot,which is the default behavior.

11.Create Graph with Two y-Axes:

A=1000;a=0.005;b=0.005;t=0:9000;Z1=A*exp(-a*t);Z2=sin(b*t);[ax,p1,p2]=plotyy(t,Z1,t,Z2,'semilogy','plot');ylabel(ax(1),'Semilog Plot');ylabel(ax(2),'Linear Plot');xlabel(ax(2),'Time');p1.LineStyle='--';p1.LineWidth=2;p2.Linewidth=2;grid(ax(1),'on');grid(ax(2),'on');

12.Display Markers at Specific Data Points on line Graph:

x=linspace(0,2*pi,100);y=sin(x);xmarkers=0:pi/2:2*pi; ymarkers=sin(xmarkers); figure plot(x,y,'b',xmarkers,ymarkers,'b*');

  

转载于:https://www.cnblogs.com/easy-wang/p/4548114.html

你可能感兴趣的文章
Hadoop Distributed File System 简介
查看>>
文档通信(跨域-不跨域)、时时通信(websocket)、离线存储(applicationCache)、开启多线程(web worker)...
查看>>
常用正则表达式
查看>>
队列的基本使用方法
查看>>
解题:USACO18FEB Taming the Herd
查看>>
ACM-括号匹配问题
查看>>
使用Python中的urlparse、urllib抓取和解析网页(一)(转)
查看>>
Linux_屏蔽360、scanv、QQ管家等IP扫描
查看>>
LeetCode 538. Convert BST to Greater Tree
查看>>
@JoinColumn
查看>>
2019浙师大校赛(浙大命题)(upc复现赛)总结
查看>>
Git多人协作常用命令
查看>>
connectionString属性server、database设置
查看>>
php下载图片
查看>>
C算法编程题(五)“E”的变换
查看>>
深入理解Web Server原理----在CC3200 WiFi模块上构建轻量级Web Server
查看>>
ecshop如何让所有页面都显视最能文章以提高SEO优化效果
查看>>
Android 6.0 使用 Apache HttpClient
查看>>
SQL server 的约束条件【转】
查看>>
iOS 弹出键盘,输入框上移问题
查看>>