Matlab 学习一

(1)学会使用帮助: help plot

官方文档网址:http://cn.mathworks.com/help/matlab/ref/plot.html


(2)简单图例


x1=20:20:100; %起点从20开始

y1=[38,44,56,67,71];
y2=[47,50,53,58,67];
y3=[30,36,45,56,63];

y4=[100,100,100,100,100];

plot(x1,y1,'b-d',x1,y2,'g-s',x1,y3,'k-^',x1,y4,'k-');

set(gca,'XTick',[0:20:100]) %改变x轴坐标间隔显示 这里间隔为20
set(gca,'YTick',[0:20:100]) %改变y轴坐标间隔显示 这里间隔为20
axis([0,100,0,100])  % axis([xmin,xmax,ymin,ymax])用这个语句调整坐标轴数字显示

xlabel('Time (s)');
ylabel('Success Rate (%)');

legend('m=2','m=4','m=8');


(3)太长数组如何输入

//注意 输入数组时候 空格...
shift+Enter

(4)盒图

官方文档网址: http://cn.mathworks.com/help/matlab/ref/plot.html,然后查询boxplot
% 例1
load carsmall
boxplot(MPG)
xlabel('All Vehicles')
ylabel('Miles per Gallon (MPG)')
title('Miles per Gallon for All Vehicles')


% 例2
load carsmall
boxplot(MPG,Origin)
title('Miles per Gallon by Vehicle Origin')
xlabel('Country of Origin')
ylabel('Miles per Gallon (MPG)')



都能正常运行

你可能感兴趣的:(Matlab)