matlab画分段纵坐标,matlab多坐标轴绘制方法
%双横坐标绘制
x1 = [0:.1:40];
y1 = 4.*cos(x1)./(x1+2);
x2 = [1:.2:20];
y2 = x2.^2./x2.^3;
hl1 = line(x1,y1,'Color','r');
ax1 = gca;
set(ax1,'XColor','r','YColor','r')
ax2 =
axes('Position',get(ax1,'Position'),...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none',...
'XColor','k'
,'YColor','k');
hl2 =
line(x2,y2,'Color','k','Parent',ax2);
双横坐标绘制
%双纵坐标轴
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');
set(get(AX(1),'Ylabel'),'String','SlowDecay')
set(get(AX(2),'Ylabel'),'String','FastDecay')
xlabel('Time (\musec)')
title('Multiple Decay Rates')
双纵坐标轴
function [ax,hlines] =
plotyyy(x1,y1,x2,y2,x3,y3,ylabels)
%PLOTYYY - Extends plotyyto include a third
y-axis
%
%Syntax: [ax,hlines]
=plotyyy(x1,y1,x2,y2,x3,y3,ylabels)
%
%Inputs: x1,y1 are thexdata and ydata for the first axes'
line
%
x2,y2 are the xdata and ydata for thesecond axes' line
%
x3,y3 are the
xdata and ydata for the thirdaxes' line
%
ylabels is a 3x1 cell array containingthe ylabel strings
%
%Outputs: ax
-
3x1 double array containing the axes'handles
%
hlines - 3x1 double array containingthe lines' handles
%
%Example:
%x=0:10;
%y1=x;
y2=x.^2; y3=x.^3;
%ylabels{1}='Firsty-label';
%ylabels{2}='Secondy-label';
%ylabels{3}='Thirdy-label';
%[ax,hlines] =plotyyy(x,y1,x,y2,x,y3,ylabels);
%legend(hlines, 'y =x','y = x^2','y = x^3',2)
%
%m-files required: none
%Author: Denis Gilbert,Ph.D., physical
oceanography
%Maurice LamontagneInstitute
%email:gilbertd@dfo-mpo.gc.ca
%Web:http://www.qc.dfo-mpo.gc.ca/iml/
%April 2000; Lastrevision: 14-Nov-2001
if nargin==6
%Useempty
strings for the ylabels
ylabels{1}=' '; ylabels{2}='
'; ylabels{3}='
';
elseif nargin > 7
error('Too many input
arguments')
elseif nargin < 6
error('Not enough input
arguments')
end
figure('units','normalized',...
'DefaultAxesXMinorTick','on','DefaultAxesYminorTick','on');
% Plot the first twolines with plotyy
[ax,hlines(1),hlines(2)] =plotyy(x1,y1,x2,y2);
cfig =
get(gcf,'color');
pos = [0.1
0.1 0.7 0.8];
offset = pos(3)/5.5;
% Reduce width of the twoaxes generated by
plotyy
pos(3) = pos(3) - offset/2;
set(ax,'position',pos);
% Determine the positionof the third axes
pos3=[pos(1) pos(2)pos(3)+offset pos(4)];
�termine the properx-limits for the
third axes
limx1=get(ax(1),'xlim');
limx3=[limx1(1)
limx1(1) + 1.2*(limx1(2)-limx1(1))];
% Bug fix 14 Nov-2001:the 1.2 scale factor in the line
above
% was contributed byMariano Garcia (BorgWarner Morse TEC
Inc)
ax(3)=axes('Position',pos3,'box','off',...
'Color','none','XColor','k','YColor','r',...
'xtick',[],'xlim',limx3,'yaxislocation','right');
hlines(3) =
line(x3,y3,'Color','r','Parent',ax(3));
limy3=get(ax(3),'YLim');
% Hide unwanted portionof the x-axis line that
lies
% between the end of thesecond and third axes
line([limx1(2)limx3(2)],[limy3(1)
limy3(1)],...
'Color',cfig,'Parent',ax(3),'Clipping','off');
axes(ax(2))
% Label all three y-axes
set(get(ax(1),'ylabel'),'string',ylabels{1})
set(get(ax(2),'ylabel'),'string',ylabels{2})
set(get(ax(3),'ylabel'),'string',ylabels{3})
x=0:10;
y1=x;
y2=x.^2; y3=x.^3;
ylabels{1}='First
y-label';
ylabels{2}='Second
y-label';
ylabels{3}='Third
y-label';
[ax,hlines] =plotyyy(x,y1,x,y2,x,y3,ylabels);
legend(hlines,'y =
x','y = x^2','y
= x^3',2)
%双纵双横坐标
tp=(0:100)/100*5;yp=8+4*(1-exp(-0.8*tp).*cos(3*tp));
%压力数据
tt=(0:500)/500*40;yt=120+40*(1-exp(-0.05*tt).*cos(tt));
%温度数据
%产生双坐标系图形
clf
reset,h_ap=axes('Position',[0.13,0.13,0.7,0.75]);%<4>生成一个窗口
set(h_ap,'Xcolor','b','Ycolor','b','Xlim',[0,5],'Ylim',[0,15]);%设定左边的X、Y轴
nx=10;ny=6;%<6>定义两个变量。给下一语句使用
pxtick=0:((5-0)/nx):5;pytick=0:((15-0)/ny):15;%<7>
X轴被分了10格,Y轴被分了6格,pxtick,pytick分别表示向量
set(h_ap,'Xtick',pxtick,'Ytick',pytick,'Xgrid','on','Ygrid','on')%画出虚线格,'Xgrid','on','Ygrid','on'起到画虚线的作用
h_linet=line(tp,yp,'Color','b');%<9>画一yp波形,对波形进行颜色设置
set(get(h_ap,'Xlabel'),'String','时间
/rightarrow(分)
')%
X横坐标命名
set(get(h_ap,'Ylabel'),'String','压力/rightarrow(/times10
^{5} Pa
)')%Y坐标命名
h_at=axes('Position',get(h_ap,'Position'));
%<12>
set(h_at,'Color','none','Xcolor','r','Ycolor','r');
%<13>
set(h_at,'Xaxislocation','top')
%<14>
set(h_at,'Yaxislocation','right','Ydir','rev')
%<15>%以上四句语句实现了上X坐标,右Y坐标
set(get(h_at,'Xlabel'),'String','/fontsize{15}/fontname{隶书
}时间
/rightarrow(分)
')
set(get(h_at,'Ylabel'),'String',' ( {/circ}C
)/fontsize{15}
/leftarrow/fontname{隶书
}零下温度
')
set(h_at,'Ylim',[0,210])
%<18>
line(tt,yt,'Color','r','Parent',h_at)%<19>画yt波形,切记不能缺少Parent
xpm=get(h_at,'Xlim');%<20>定义新变量
txtick=xpm(1):((xpm(2)-xpm(1))/nx):xpm(2);%<21>
xpm(1)为0,xpm(2)为40,在哪条语句定义的?
tytick=0:((210-0)/ny):210;
%<22>%Y坐标分格
set(h_at,'Xtick',txtick,'Ytick',tytick)
%<23>
matlab画分段纵坐标,matlab多坐标轴绘制方法相关推荐
- matlab编程画分段函数,matlab画分段函数 求程序
你好,你的问题好像没太描述清楚. 分段函数绘图实际很简单,我给你举个例子吧. 分段函数如下: 对该函数绘图,首先应该利用matlab建一个函数ff(x),如下:function Y = ff(X) i ...
- matlab画置信区间图,matlab绘制带置信区间的双y轴图形 | 学步园
matlab的双y轴网上有很多方法,但是带置信区间的双y轴就很少了,并且由于网上给的例子一般都是使用红蓝两色,对于只想使用黑色或者灰色的俺们来说太鲜艳啦~ 上图为使用matlab绘制的双y轴带置信区间 ...
- 怎样用MATLAB画二次函数曲线,matlab画二次函数图像
[8 70 118 100 9 0 5]; 以上是每一个 X 和 Y 对应的坐标,请问如何编程能够绘制平滑曲线,这个图形就像二次函数一样的 如果要在图中绘制一条直线加上 y=...... MATLAB ...
- 用matlab画干涉条纹图,matlab干涉条纹处理
基于matlab的等倾干涉实 验仿真黄强煌 2017.12.25 目录 Cont... [5] 符运良. MATLAB 在光学教学中的应用 . 华南热带农业大学学报, [J] 2004, (3 : 1 ...
- matlab画圆柱,使用Matlab画出圆台圆锥圆柱
<使用Matlab画出圆台圆锥圆柱>由会员分享,可在线阅读,更多相关<使用Matlab画出圆台圆锥圆柱(5页珍藏版)>请在人人文库网上搜索. 1.用Matlab画圆柱圆台圆锥自 ...
- matlab图像抽象化,一种彩色图像抽象化绘制方法
一种彩色图像抽象化绘制方法 [专利摘要]本发明公开了一种彩色图像抽象化绘制方法,该方法将输入待处理的图像,对图像在RGB颜色空间中R.G.B通道分别求其梯度,并对三通道的梯度进行融合,得到图像的初始轮 ...
- 前端怎么画三角形_WEB前端-CSS三角形绘制方法
我们的网页因为 CSS 而呈现千变万化的风格.这一看似简单的样式语言在使用中非常灵活,只要你发挥创意就能实现很多比人想象不到的效果.特别是随着 CSS3 的广泛使用,更多新奇的 CSS 作品涌现出来. ...
- matlab 画多边形,[转载]matlab多边形绘制
题目: 例如,在matlab里画出下图,并填充其中,1 2 3 4 5 6 7 是点的编号坐标分别为 1(1,1), 2(1,2), 3(2,2), 4(3,2), 5(3,1), 6(2,1), 7 ...
- matlab双纵坐标的绘图命令_[转载]MATLAB画双纵坐标 plotyy的用法 对数坐标
具有两个纵坐标标度的图形 在MATLAB中,如果需要绘制出具有不同纵坐标标度的两个图形,可以使用plotyy绘图函数.调用格式为: plotyy(x1,y1,x2,y2) 其中x1,y1对应一条曲线, ...
最新文章
- 机器人瓦力船长机器人_警察“瓦力”来啦!机器人巡逻南京路 这样的它你喜欢吗?...
- 深度学习和机器学习_面试问题(二)
- tomcat-清除缓存
- Hive mac 客户端工具DbVisualizer配置
- HttpClient超时重复提交问题
- Jenkins搭建的几个坑记下
- MCGS与PLC通讯不上
- jqGrid('setSelection',rowid)报Cannot read property 'multiple' of undefined
- 上周热点回顾(7.9-7.15)
- windows下的终端工具和产品力
- ORACLE获取某个时间段之间的月份列表和日期列表
- vscode设置go环境
- 跳转的两种方式(转发与重定向)
- 宝马 android手机同步,BMW将发布无线安卓互联系统,CarPlay终于不再一家独大!
- 《玩透嵌入式C的角角落落》当你需要循环体至少执行一次时,选择do
- 575. 分糖果【我亦无他唯手熟尔】
- 基于微信的图书馆服务系统的设计与实现
- python中randon随机数
- 破解人脸识别被判七年!打击黑产,鼓励人脸识别技术健康发展
- Quartus Prime v18.1 standard-QuartusPrimeV18.1标准版安装过程
热门文章
- 精灵混合加密系统_多种解锁体验,小益天猫精灵智能指纹锁E206T
- 18年上半年读书清单一览
- 精心收集的Hadoop学习资料
- 国网GIM设备三维模型要求细则 - 避雷器
- 永恒之柱2显示服务器,永恒之柱2游戏黑屏是什么原因怎么解决_画面显示不全解决方法教程攻略...
- 页面(HTML)优化的方法
- Oracle经典sql语句总结@sql-plus重点函数串讲与sql语句案例@中文排序详讲).doc
- [解决方法] 如何将训练过程保存为视频
- 拓嘉启远:拼多多层级提高后有什么用?
- 为什么Java单元测试不支持控制台输入