大家好,我是带我去滑雪!
主函数matlab代码:
function PlotAxisAtOrigin(x,y);
if nargin == 2 plot(x,y);hold on;
elsedisplay(' Not 2D Data set !')
end;
X=get(gca,'Xtick');
Y=get(gca,'Ytick');
XL=get(gca,'XtickLabel');
YL=get(gca,'YtickLabel');
Xoff=diff(get(gca,'XLim'))./100;
Yoff=diff(get(gca,'YLim'))./100;
plot(get(gca,'XLim'),[0 0],'k');
plot([0 0],get(gca,'YLim'),'k');for i=1:length(X)plot([X(i) X(i)],[0 Yoff],'-k');
end;
for i=1:length(Y)plot([Xoff, 0],[Y(i) Y(i)],'-k');
end;
text(X,zeros(size(X))-2.*Yoff,XL);
text(zeros(size(Y))-3.*Xoff,Y,YL);
box off;
axis off;
set(gcf,'color','w');
调用函数,并指定函数表达式:
x = linspace(-pi,pi);
y = sin(x);
PlotAxisAtOrigin(x,y)
输出结果:
更多优质内容持续发布中,请移步主页查看。
点赞+关注,下次不迷路!