您的位置:首页 > 编程语言 > MATLAB

MATLAB绘图

2011-06-02 09:29 190 查看
以前用MATLAB绘图,都很简单,没想到居然还可以这么丰富~~

绘制一幅正弦曲线:

%adjust default figure properties to improve quality
figure;
set(gcf,...
    'DefaultLineLineWidth',1,'DefaultAxesLineWidth',.5,...
    'DefaultAxesFontName','Helvetica',...
    'DefaultAxesFontSize',20,...
    'DefaultAxesTickLength',[0.02,0.02],... 
    'DefaultAxesXMinorTick','on','DefaultAxesYMinorTick','on');
set(gcf,'DefaultLineMarkerSize',8);
 
% plot your data here
x=0:0.3:2*pi;
y=sin(x);
plot(x,y,'o-','displayname','$y=/sin (x)</p>);
xlabel('$x</p>,'interpreter','latex');
ylabel('$y</p>,'interpreter','latex');
h=legend('show');
set(h,'interpreter','latex');
title('http://asc.2dark.org');
 
%save your figure and export to eps format
hgsave('example.fig');
print('-depsc','example.eps');




绘制坐标轴紧邻的子图:

x=0:0.3:2*pi;
 
figure;
h1=subplot(1,3,1);
plot(x,sin(x));
h2=subplot(1,3,2);
plot(x,cos(x));
h3=subplot(1,3,3);
plot(x,sin(x-1));
 
set(h1,'position',[0.1,0.1,0.26,0.8]);
set(h2,'position',[0.36,0.1,0.26,0.8],'yticklabel','');
set(h3,'position',[0.62,0.1,0.26,0.8],'yaxislocation','right');
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: