matlab系列文章:👉 目录 👈

sd.xlsx,以相邻两列数据绘制散点图并标注;以第 1,2,4 列数据绘制空间散点图mesh、surf 绘制曲面
z
=
f
(
x
,
y
)
=
s
i
n
x
2
+
y
2
x
2
+
y
2
,
x
.
y
∈
[
−
10
,
10
]
z=f(x,y)=\frac{sin{\sqrt{x^2+y^2}}}{\sqrt{x^2+y^2}},x.y\in[-10,10]
z=f(x,y)=x2+y2sinx2+y2,x.y∈[−10,10]>> [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

数组 [ 2 , 5 , 10 , 12 , 13 , 7 , 2 , 10 , 4 , 6 , 8 , 8 , 4 , 7 , 8 ] [2,5,10,12,13,7,2,10,4,6,8,8,4,7,8] [2,5,10,12,13,7,2,10,4,6,8,8,4,7,8]
>> % 读数据
>> 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)

