matlab中双x轴,【转】MATLAB:双X轴曲线绘图
该函数调用格式为:
[ax,hl1,hl2] = plotxx(x1,y1,x2,y2,xlabels,ylabels);
参数说明:
ax是坐标轴的句柄。h1 和 h2 是两条曲线的句柄。x1,y1,x2,y2
是绘图数据。Xlabels,Ylabels是X轴和Y州标注内容对应的细胞结构。
例:
D = linspace(-100,0,50);%Y轴数据
S = linspace(34,32,50);%上侧X轴数据
T = 10*exp(D/40);%下侧X轴数据
xlabels{1} = 'Temperature (C)';%下侧X轴内容标注
xlabels{2} = 'Salinity';%上侧X轴内容标注
ylabels{1} = 'Depth(m)';%左侧Y轴内容标注
ylabels{2} = 'Depth(m)';%右侧Y轴内容标注
[ax,hlT,hlS] = plotxx(T,D,S,D,xlabels,ylabels);%绘制双X轴曲线
附件:plotxx.m
function [ax,hl1,hl2] = plotxx(x1,y1,x2,y2,xlabels,ylabels);
%PLOTXX - Create graphs with x axes on both top and
bottom %
%Similar to PLOTYY, but ...
%the independent variable is on the y-axis, %and both dependent variables are on the x-axis.
%
%Syntax: [ax,hl1,hl2] = plotxx(x1,y1,x2,y2,xlabels,ylabels);
%
%Inputs: X1,Y1 are the data for the first line (black)
% X2,Y2 are the data for the second line (red)
% XLABELS is a cell array containing the two x-labels
% YLABELS is a cell array containing the two y-labels
%
%The optional output handle graphics objects AX,HL1,HL2
%allow the user to easily change the properties of the plot.
%
%Example: Plot temperature T and salinity S % as a function of depth D in the ocean
%
%D = linspace(-100,0,50);
%S = linspace(34,32,50);
%T = 10*exp(D/40);
%xlabels{1} = 'Temperature (C)';
%xlabels{2} = 'Salinity';
%ylabels{1} = 'Depth(m)';
%ylabels{2} = 'Depth(m)';
%[ax,hlT,hlS] = plotxx(T,D,S,D,xlabels,ylabels);
%The code is inspired from page 10-26 (Multiaxis axes)
%of the manual USING MATLAB GRAPHICS, version 5.
%
%Tested with Matlab 5.3.1 and above on PCWIN
%Author: Denis Gilbert, Ph.D., physical oceanography
%Maurice Lamontagne Institute, Dept. of Fisheries and Oceans
Canada
%email: Web: http://www.qc.dfo-mpo.gc.ca/iml/
%November 1997; Last revision: 01-Nov-2001
if nargin < 4
error('Not enough input
arguments')
elseif nargin==4
%Use empty strings for the
xlabels
xlabels{1}=' '; xlabels{2}='
'; ylabels{1}=' '; ylabels{2}=' ';
elseif nargin==5
%Use empty strings for the
ylabel
ylabels{1}=' '; ylabels{2}='
';
elseif nargin > 6
error('Too many input
arguments')
end
if length(ylabels) == 1
ylabels{2} = ' ';
end
if ~iscellstr(xlabels) error('Input xlabels must be a
cell array')
elseif ~iscellstr(ylabels) error('Input ylabels must be a
cell array')
end
hl1=line(x1,y1,'Color','k');
ax(1)=gca;
set(ax(1),'Position',[0.12 0.12 0.75 0.70])
set(ax(1),'XColor','k','YColor','k');
ax(2)=axes('Position',get(ax(1),'Position'),...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none',...
'XColor','r','YColor','k');
set(ax,'box','off')
hl2=line(x2,y2,'Color','r','Parent',ax(2));
%label the two x-axes
set(get(ax(1),'xlabel'),'string',xlabels{1})
set(get(ax(2),'xlabel'),'string',xlabels{2})
set(get(ax(1),'ylabel'),'string',ylabels{1})
set(get(ax(2),'ylabel'),'string',ylabels{2})
【转载】http://hi.baidu.com/hyyly520/blog/item/21cb2e2260ea3349ad34de07.html
matlab中双x轴,【转】MATLAB:双X轴曲线绘图相关推荐
- matlab 如何axis,在matlab中axis是什么意思,matlab中axis的用法
在matlab中axis是什么意思轴在matlab中是什么意思,matlab中的Axis是指在绘图中通常使用axis函数来设置坐标值的范围,在matlab的命令窗口中输入doc轴或help轴即可获得该 ...
- 在MATLAB中使用数学符号,在matlab中怎么输入特殊符号 function在MATLAB中怎么用
导航:网站首页 > 在matlab中怎么输入特殊符号 function在MATLAB中怎么用 在matlab中怎么输入特殊符号 function在MATLAB中怎么用 相关问题: 匿名网友: 一 ...
- matlab中的timer模块,[转载]Matlab中Timer的使用
Matlab中Timer的使用 鉴于Matlab中缺乏多线程机制,使用Timer无疑是一个很重要的工具,Matlab中Timer是一个Java对象. (1)Timer 的定义 t=timer(); 设 ...
- m 文件 dll matlab 中调用_如何在matlab中调用python程序
现在python很火,很多代码都是python写的,如果你和我一样,习惯了使用matlab,还想在matlab中调用Python的代码,应该怎么办呢?其中一条思路:首先在matlab中调用系统脚本命令 ...
- matlab中m文件是什么,MATLAB中M文件的使用
运行方法: 使用matlab的时候,可以在"Command Window"内直接书写matlab代码,也可以将代码保存到M文件中,然后运行该文件.使用matlab主界面菜单&quo ...
- matlab中的bar3()函数的x-y轴的区间取值方法
一.bar3(Z)的用法 在matlab中,可以使用bar3()函数来解决三维的柱状图绘制问题,假设有下面的代码,得到图像为: a = [1,1,1;2,2,2;3,3,3] bar3(a); 二.b ...
- matlab中codegen是什么,从 MATLAB 代码生成 C/C++ 代码。 - MATLAB codegen
- MathWorks 中国...
-c生成 C/C++ 代码,但不调用 make 命令. -config:dll使用默认配置参数生成动态 C/C++ 库. -config:exe使用默认配置参数生成静态 C/C++ 可执行文件. -c ...
- matlab中的神经网络怎么用,matlab怎么搭建神经网络
1.怎样用matlab建立bp神经网络 net=train(net, p, t);把这句改成net=train(net, p', t');试试,matlab应该默认使用列向量.或者直接使用matlab ...
- matlab中仿真丢包,使用MATLAB进行误比特率(BER)仿真----转载
原作者:James E. Gilley 译者:H. X. Xia 1. 引言 由于Matlab 具有简单的描述语言和优秀的数据图形化能力,MATLAB成为进行数字通信系统仿真的理想工具.在数字通信领域 ...
- matlab中如何输入积分,在matlab中怎么输入特殊符号,Matlab的符号积分
一.文档中的Text Properties: 下标用 _(下划线) 上标用^ (尖号) 斜体 \it 黑体 \bf << \ll >> \gg 正负 \pm 左箭头 \left ...
最新文章
- React Namespaced Components
- 利用CNN来检测伪造图像
- SAP WM LT15不能取消二步法确认场景中只做过第一步确认的TO单
- 网络营销——网站权重并不是判断网站营销水平的唯一标准
- Windows Phone Dev Notes-如何使用ConnectionSettingsTask 来启动连接设置页面
- ITK:获取PointSet的边界框
- c#调用外部dll详解
- post发送byte数组_KAFKA消息发送
- 谷歌如何在设计上脱胎换骨
- HIVE json格式数据的处理
- Vivado 2015.4 安装教程(含license)
- 我在51CTO微职位学PMP_飘过攻略及心得分享
- 深度学习 deep learning 花书 pdf下载
- 【Rainmeter】简简单单的 一言 小皮肤
- java通过SMTP发送QQ邮件(参考自龙果学院)
- 光伏电站清扫机器人_光伏电站清扫机器人_雷曼科林
- Part2 正交、行列式、特征值
- zotero+better bibtex+overleaf(latex):如何批量导出参考文献及相关设置
- 通用计算机与嵌入式的比较,嵌入式系统与通用计算机系统相比有什么特点?如题 谢谢了...
- 见缝插针php源码,见缝插针 小游戏源码