再问多纵坐标图像画法?
看了http://forum.vibunion.com/thread-24244-1-1.html这个帖子的做法,想问个变化点的问题,自己试了几次没成功。已经用plotyyy画出了三个函数图象。但我的三个函数都是拟合出来的。我想在图上再把拟合前的基本实验点用‘*'标出来,该怎么用?
由于在原帖子里回复人气不足,所以再发新帖 简单修改一下就行了
function = plotyyy(x1,y1,x2,y2,x3,y3,ylabels)
%PLOTYYY - Extends plotyy to include a third y-axis
%Syntax: = plotyyy(x1,y1,x2,y2,x3,y3,ylabels)
%Inputs: x1,y1 are the xdata and ydata for the first axes' line
% x2,y2 are the xdata and ydata for the second axes' line
% x3,y3 are the xdata and ydata for the third axes' line
% ylabels is a 3x1 cell array containing the ylabel strings
%Outputs: ax - 3x1 double array containing the axes' handles
% hlines - 3x1 double array containing the lines' handles
%Author: Denis Gilbert, Ph.D., physical oceanography
%Maurice Lamontagne Institute
%Dept. of Fisheries and Oceans Canada
%email: gilbertd@dfo-mpo.gc.ca
%Web: http://www.qc.dfo-mpo.gc.ca/iml/
%April 2000; Last revision: 14-Nov-2001
if nargin==6
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');
= plotyy(x1,y1,x2,y2);
cfig = get(gcf,'color');
pos = ;
offset = pos(3)/5.5;
pos(3) = pos(3) - offset/2;
set(ax,'position',pos);
pos3=;
limx1=get(ax(1),'xlim');
limx3=;
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');
line(,,...
'Color',cfig,'Parent',ax(3),'Clipping','off');
axes(ax(2))
set(hlines(1),'marker','*');
set(hlines(2),'marker','*');
set(hlines(3),'marker','*');
set(get(ax(1),'ylabel'),'string',ylabels{1})
set(get(ax(2),'ylabel'),'string',ylabels{2})
set(get(ax(3),'ylabel'),'string',ylabels{3}) 我想标出的是原来较少的那几个基本数据点。
能帮我看下我的程序吗
clear
a=0.411;
n=0.492;
c=20;
R=; %差压计读数
H1=; %压力表读数
H2=; %真空表读数
N1=; %功率表格数
K=; %电机效率
Q=a*(R.^n), %计算并输出流量l/s
U1=(4*1000*Q)/(pi*39^2),
U2=(4*1000*Q)/(pi*31^2), %计算并输出进出口流速m/s
H=0.1+1000*H2/9.8+H1/10+(U2.^2-U1.^2)/(2*9.8);
H %计算并输出扬程
N=N1.*K*c, %轴功率w
M=(H.*Q*9.8)./N, %离心泵效率
p1=polyfit(Q,H,4),
p2=polyfit(Q,N,4),
p3=polyfit(Q,M,4), %分别拟合扬程,轴功,效率关于流量的关系
x=0:.01:4;
y1=polyval(p1,x);
y2=polyval(p2,x);
y3=polyval(p3,x);
ylabels{1}='扬程/m';
ylabels{2}='轴功率/w';
ylabels{3}='离心泵效率/%';
= plotyyy(x,y1,x,y2,x,y3,ylabels);
legend(hlines, 'H','N','效率',2)
gridon
我的意思是想把(Q,H) (Q,N) (Q,M)用‘’*'标出来,如果改成上面的,岂不是把x=0:.01:4每个点都标记了? clear
a=0.411;
n=0.492;
c=20;
R=; %差压计读数
H1=; %压力表读数
H2=; %真空表读数
N1=; %功率表格数
K=; %电机效率
Q=a*(R.^n), %计算并输出流量l/s
U1=(4*1000*Q)/(pi*39^2),
U2=(4*1000*Q)/(pi*31^2), %计算并输出进出口流速m/s
H=0.1+1000*H2/9.8+H1/10+(U2.^2-U1.^2)/(2*9.8);
H %计算并输出扬程
N=N1.*K*c, %轴功率w
M=(H.*Q*9.8)./N, %离心泵效率
p1=polyfit(Q,H,4),
p2=polyfit(Q,N,4),
p3=polyfit(Q,M,4), %分别拟合扬程,轴功,效率关于流量的关系
x=0:.01:4;
y1=polyval(p1,x);
y2=polyval(p2,x);
y3=polyval(p3,x);
ylabels{1}='扬程/m';
ylabels{2}='轴功率/w';
ylabels{3}='离心泵效率/%';
figure('units','normalized',...
'DefaultAxesXMinorTick','on','DefaultAxesYminorTick','on');
= plotyy(x,y1,x,y2);
cfig = get(gcf,'color');
pos = ;
offset = pos(3)/5.5;
pos(3) = pos(3) - offset/2;
set(ax,'position',pos);
pos3=;
limx1=get(ax(1),'xlim');
limx3=;
hold on;
= plotyy(Q,H,Q,N);
set(hlines2(1),'linestyle','none','marker','*');
set(hlines2(2),'linestyle','none','marker','*');
ax(3)=axes('Position',pos3,'box','off',...
'Color','none','XColor','k','YColor','r',...
'xtick',[],'xlim',limx3,'yaxislocation','right');
hlines(3) = line(x,y3,'Color','r','Parent',ax(3));
limy3=get(ax(3),'YLim');
line(,,...
'Color',cfig,'Parent',ax(3),'Clipping','off');
hlines(3) = line(x,y3,'Color','r','Parent',ax(3));
hlines2(3) = line(Q,M,'Color','r','Parent',ax(3));
set(hlines2(3),'linestyle','none','marker','*');
axes(ax(2))
set(get(ax(1),'ylabel'),'string',ylabels{1})
set(get(ax(2),'ylabel'),'string',ylabels{2})
set(get(ax(3),'ylabel'),'string',ylabels{3}) 谢谢happy教授,受益匪浅!!!! 我也有同样的问题,谢谢happy教授!
页:
[1]