本文共 1181 字,大约阅读时间需要 3 分钟。
x = logspace(-1, 1, 100); 从10^-1 - 10^1之间的100个点y = x.^2;subplot(2,2,1); %subplot 是把多个图形画在一个平面上,此处表示的意思就是共两行两列,我这个图形在第一个plot(x,y); title('Plot');subplot(2,2,2);semilogx(x,y); %对x取对数,就是x变成了从-1 ~ 1的范围title('scmilogx');subplot(2,2,3);semilogy(x,y);title('scmilogy'); %对y取对数subplot(2,2,4);loglog(x, y); %表示对x和y都取对数title('Loglog');
x = 0:0.01:20;y1 = 200*exp(-0.05*x).*sin(x);y2 = 0.8*exp(-0.5*x).*sin(x);[AX, H1, H2] = plotyy(x,y1, x, y2);set(get(AX(1), 'Ylabel'), 'String', 'Left Y-axis');set(get(AX(2), 'Ylabel'), 'String', 'Right Y-axis');title('Labeling plotyy');set(H1, 'LineStyle', '--'); set(H2, 'LineStyle', ':');
其实也很简单,就是一个坐标画了两个图形,两个y值。
y = randn(1, 1000);subplot(2, 1, 1);hist(y, 10); %分成10个title('统计图')
比较有意思的就属这个hist函数了,表示你要分几个。
x =[1 2 5 6 7]; y=[x; 1:5];subplot(1,3, 1); bar(x); subplot(1,3, 2); bar(y);subplot(1,3, 3); bar3(y);
我觉得图更好看点,,,上图、
压栈操作更是一种骚气。。
x =[1 2 5 6 7]; y=[x; 1:5];subplot(1,3, 1); bar(x,'stacked'); subplot(1,3, 2); bar(y,'stacked');subplot(1,3, 3); bar3(y,'stacked');
倒过来显示的话,那就是
barh(y,'stacked');
5、扇形图
x = [10 20 30 5];subplot(1,3,1); pie(x);subplot(1,3,2); pie(x, [0 0 0 1]);subplot(1,3,2); pie(x, [0,0,0,1]);subplot(1,3,3); pie3(x, [0 0 0 1]);