本文共 952 字,大约阅读时间需要 3 分钟。
本实验取材于中南大学《MATLAB与科学计算》
今天学习主要有两种内容,第一、对数坐标图,第二、统计图 一、对数坐标图semilogx(x1,y1,选项1,x2,y2,选项2,...)semilogy(x1,y1,选项1,x2,y2,选项2,....)loglog(x1,y1,选项1,x2,y2,选项2,...)
例子:绘出1/x的函数图像
x=0:0.1:10;y=1./x;subplot(2,2,1);plot(x,y)title('plot(x,y)');subplot(2,2,2);semilogx(x,y)title('semilogx(x,y)');grid onsubplot(2,2,3);semilogy(x,y);title('semilogy(x,y)');grid onsubplot(2,2,4);loglog(x,y)title('loglog(x,y)');grid on
总结:其实就是对数的转换,你想转换x那就semilogx,如果想转换y那就semilogy,如果想都转换一样,那就是loglog
二、统计图 1、条形图
格式bar(y,style)
ps:style可以有两类,grouped簇状分组 stacked 为堆积分组
代码:
hold offx=[2015,2016,2017];y=[68,80,115,98,102;75,88,102,99,110;81,86,125,105,115];bar(x,y)title('Group')
图片
hist(x,y)
代码
>> y=randn(500,1);>> subplot(2,1,1);>> hist(y);>> title('高斯分布直方图');>> subplot(2,1,2);>> x=-3:0.2:3;>> hist(y,x);>> title('指定区间中心点的直方图')>>
图片
pie(x,y)
代码
score=[5,17,23,9,4];ex=[0,0,0,0,1];holdpie(score,ex)legend('优秀','良好','中等','及格','不及格','location','eastoutside')
图片
转载地址:http://hurd.baihongyu.com/