sd.xlsx
,以相邻两列数据绘制散点图并标注;以第 1,2,4 列数据绘制空间散点图,
在同一幅图;
,
在同一幅图不同窗口
作竖直、水平、立体柱状图、饼状图
,
,
,
mesh
、surf
绘制曲面与锥面
所围成的立体
截马鞍面
>> [num1]=xlsread('F:\sd.xlsx',1,'A1:B191')
>> [num2]=xlsread('F:\sd.xlsx',1,'D1:E191')
>> [num3]=xlsread('F:\sd.xlsx',1,'G1:H40')
>> scatter(num1(:,[1]),num1(:,[2]),[],'b','filled')
>> hold on
>> scatter(num2(:,[1]),num2(:,[2]),[],'r','filled')
>> hold on
>> scatter(num3(:,[1]),num3(:,[2]),[],'black','filled')
>> title('shu ju A B C san dian tu')
>> legend('shu ju zu A','shu ju zu B','shu ju zu C')
>> scatter3(num1(:,[1]),num1(:,[2]),num2(:,[1]),'filled')
,
在同一幅图
>> x = 0:0.01:2*pi
>> y1 = sin(x)
>> y2 = cos(x)
>> plot(x,y1,x,y2)
>> title('The graph of sinx and cosx','color','b')
>> legend('y=cosx','y=sinx')
,
在同一幅图不同窗口
>> subplot(1,2,1)
>> plot(x,y1)
>> title('y=sinx')
>> box off
>>
>> subplot(1,2,2)
>> plot(x,y2)
>> title('y=cosx')
>> box off
数组
>> % 读数据
>> data = [2,5,10,12,13,7,2,10,4,6,8,8,4,7,8]
>> bar(data)
>> barh(data)
>> bar3(data)
>> pie(data)
,
,
,
>> t = 0:0.01:6*pi
>> x = exp(0.3*t).*sin(t)
>> y = exp(0.3*t).*cos(t)
>> z = exp(0.3*t)
>> plot3(x,y,z)
>> x = -10:0.25:10
>> y = -10:0.25:10
>> [x,y] = meshgrid(x,y)
>> R = (x.^2+y.^2).^(1/2)
>> z = sin(R)./R
>>
>> mesh(x,y,z)
>>
>>
与锥面
所围成的立体
>> x=-2:0.01:2;
>> y=-2:0.01:2;
>> [x,y]=meshgrid(x,y);
>> z1=real(sqrt(4-x.^2-y.^2));
>> z2=sqrt(x.^2+y.^2)-2;
>> surf(x,y,z1),shading flat
>> hold on
>> z2(z2>0)=NaN;
>> surf(x,y,z2),shading flat
截马鞍面
>> x = -20:.1:20
>> y = -20:.1:20
>> [x,y]=meshgrid(x,y)
>> z1 = 2*x-3*y
>> z2 = x.^2-2*y.^2
>> mesh(x,y,z1)
>> hold on
>> mesh(x,y,z2)