This commit is contained in:
2025-10-20 10:11:16 +08:00
parent 49047b316d
commit e1c5587623
25 changed files with 177 additions and 0 deletions

6
c5_5_11.m Normal file
View File

@@ -0,0 +1,6 @@
x=-1:1;
y=[1,2,3,4,5;1,2,1,2,1;5,4,3,2,1];
subplot(1,2,1);bar(x,y,'grouped');
title('Grouped');axis([-3,3,0,6]);
subplot(1,2,2);barh(x,y,'stacked');
title('Stack');

4
c5_5_13.m Normal file
View File

@@ -0,0 +1,4 @@
y=randn(500,1);
theta=y*pi;
rose(theta);
title('');

3
c5_5_14.m Normal file
View File

@@ -0,0 +1,3 @@
pie([7,17,23,19,5],[0,0,0,0,1]);
title('');
legend('','','','','');

6
c5_5_15.m Normal file
View File

@@ -0,0 +1,6 @@
t=0:2*pi/8:2*pi;
t=[t,t(1)];
x=sin(t);
y=cos(t);
fill(x,y,'r');
axis equal;axis([-1.5,1.5,-1.5,1.6])

8
c5_5_16.m Normal file
View File

@@ -0,0 +1,8 @@
x=0:0.35:7;
y=2*exp(-0.5*x);
subplot(1,3,1);scatter(x,y,'green');
title('scatter(x,y,''green'')');axis([0,7,0,2]);
subplot(1,3,2);stairs(x,y,'b');
title('stairs(x,y,''b'')');axis([0,7,0,2]);
subplot(1,3,3);stem(x,y,'k');
title('stem(x,y,''k'')');axis([0,7,0,2]);

8
c5_5_17.m Normal file
View File

@@ -0,0 +1,8 @@
x=-pi:pi/8:pi;
y=sin(x);
subplot(2,2,1);compass(x,y);
title('');
subplot(2,2,2);feather(x,y);
title('');
subplot(2,1,2);quiver(x,y);
title('');

8
c5_5_18.m Normal file
View File

@@ -0,0 +1,8 @@
t=0:pi/50:2*pi;
x=8*cos(t);
y=4*sqrt(2)*sin(t);
z=-4*sqrt(2)*sin(t);
plot3(x,y,z,'p');
title('Line in 3-D Space');
text(0,0,0,'origin');
xlabel('X'),ylabel('Y'),zlabel('Z');grid;

12
c5_5_20.m Normal file
View File

@@ -0,0 +1,12 @@
x=0:0.1:2*pi;
[x,y]=meshgrid(x);
z=sin(y).*cos(x);
subplot(2,2,1);mesh(x,y,z);
xlabel('x-axis'),ylabel('y-axis'),zlabel('z-axis');
title('mesh');
subplot(2,2,2);surf(x,y,z);
xlabel('x-axis'),ylabel('y-axis'),zlabel('z-axis');
title('surf');
subplot(2,1,2);plot3(x,y,z);
xlabel('x-axis'),ylabel('y-axis'),zlabel('z-axis');
title('plot3');

18
c5_5_21.m Normal file
View File

@@ -0,0 +1,18 @@
m=30;
z=1.2*(0:m)/m;
r=ones(size(z));
theta=(0:m)/m*pi*2;
x1=r'*cos(theta);
y1=r'*sin(theta);
z1=z'*ones(1,m+1);
x=(-m:2:m)/m;
x2=x'*ones(1,m+1);
y2=r'*cos(theta);
z2=r'*sin(theta);
surf(x1,y1,z1);
axis equal,axis off;
hold on;
surf(x2,y2,z2);
axis equal,axis off;
title('');
hold off;

13
c5_5_22.m Normal file
View File

@@ -0,0 +1,13 @@
[x,y] = meshgrid(-10:0.2:10);
z1 = (x.^2-2*y.^2) + eps;
a=input('a=?');
z2=a*ones(size(x));
subplot(1,2,1);
mesh(x,y,z1);hold on;mesh(x,y,z2);
v=[-10,10,-10,10,-100,100];axis(v);grid;
hold off
r0=abs(z1-z2)<=1;
xx=r0.*x;yy=r0;zz=r0.*z2;
subplot(1,2,2);
plot3(xx(r0~=0),yy(r0~=0),zz(r0~=0),'*');
axis(v);grid;

14
c5_5_23.m Normal file
View File

@@ -0,0 +1,14 @@
[x,y]=meshgrid(-8:0.5:8);
z=sin(sqrt(x.^2+y.^2));
subplot(2,2,1);
meshc(x,y,z);
title('meshc(x,y,z)');
subplot(2,2,2);
meshz(x,y,z);
title('meshz(x,y,z)');
subplot(2,2,3);
surfc(x,y,z);
title('surfc(x,y,z)');
subplot(2,2,4);
surfl(x,y,z);
title('surfl(x,y,z)');

5
c5_5_24.m Normal file
View File

@@ -0,0 +1,5 @@
t=0:pi/20:2*pi;
[x,y,z]=cylinder(2+sin(t),30);
subplot(1,3,1);surf(x,y,z);
[x,y,z]=sphere;
subplot(1,3,1);surf(x,y,z);

6
c_5_5_12.m Normal file
View File

@@ -0,0 +1,6 @@
y=randn(500,1);
subplot(1,2,1);
hist(y);title('');
x=-4:0.1:4;
subplot(1,2,2)
hist(y,x);title('');

5
p121.m Normal file
View File

@@ -0,0 +1,5 @@
x=1:2:9;
y=[1,3,5,2,6;2,4,5,6,2;5,4,7,2,2]';
area(x,y);
grid on;
title('');

5
plotxy11.m Normal file
View File

@@ -0,0 +1,5 @@
x = 0:0.1:4*pi;
plot(x,sin(x)+sin(3*x));
set(gca,'ytick',[-1,-0.3,0.1,1]);
set(gca,'yticklabel',{'','','',''});
grid on;

5
plotxy13.m Normal file
View File

@@ -0,0 +1,5 @@
x=0:0.1:4*pi;
subplot(2,2,1);plot(x,sin(x));
subplot(2,2,2);plot(x,cos(x));
subplot(2,2,3);plot(x,sin(x).*exp(-x/5));
subplot(2,2,4);plot(x,x.^2);

7
plotxy14.m Normal file
View File

@@ -0,0 +1,7 @@
t=0:0.1:2*pi;
x=3*cos(t);
y=sin(t);
subplot(2,2,1);plot(x,y);axis normal
subplot(2,2,2);plot(x,y);axis square
subplot(2,2,3);plot(x,y);axis equal
subplot(2,2,4);plot(x,y);axis equal tight

8
plotxy15.m Normal file
View File

@@ -0,0 +1,8 @@
x=0:0.1:2*pi;
y1=sin(x);
y2=exp(-x);
plot(x,y1,'--*',x,y2,':o');
xlabel('t = 0 to 2\pi');
ylabel('values of sin(t) and e^{-x}');
title('Function Plots of sin(t) and e^{x}');
legend('sin(t)','e^{-x}');

4
plotxy16.m Normal file
View File

@@ -0,0 +1,4 @@
x=0:0.1:2*pi;
plot(x,sin(x),x,cos(x));
text(pi/4,sin(pi/4),'\leftarrow sin(q\pi/4)=0.707');
text(5*pi/4,cos(5*pi/4),'cos(5\pi/4) = -0.707 \rightarrow','HorizontalAlignment','right');

3
plotxy20.m Normal file
View File

@@ -0,0 +1,3 @@
x=randn(10000,1);
hist(x,25);
set(findobj(gca,'type','patch'),'edgecolor','w');

5
plotxyz01.m Normal file
View File

@@ -0,0 +1,5 @@
x=linspace(-2,2,25);
y=linspace(-2,2,25);
[xx,yy]=meshgrid(x,y);
zz=xx.*exp(-xx.^2-yy.^2);
surf(xx,yy,zz);

3
plotxyz03.m Normal file
View File

@@ -0,0 +1,3 @@
[x,y,z]=peaks;
meshz(x,y,z);
axis tight

3
plotxyz05.m Normal file
View File

@@ -0,0 +1,3 @@
[x,y,z]=peaks;
meshc(x,y,z);
axis tight

4
plotxyz091.m Normal file
View File

@@ -0,0 +1,4 @@
subplot(2,2,1);ezmesh('sin(x)/x*sin(y)/y');
subplot(2,2,2);ezsurf('sin(x*y)/(x*y)');
subplot(2,2,3);ezmeshc('sin(x)/x*sin(y)/y');
subplot(2,2,4);ezsurfc('sin(x*y)/(x*y)');

14
ployxyz011.m Normal file
View File

@@ -0,0 +1,14 @@
x = 3 : 6;
y = 5 : 9;
[xx,yy]=meshgrid(x,y);
zz=xx.*yy;
subplot(2,2,1);mesh(xx);
title('xx');axis tight
subplot(2,2,2);mesh(yy);
title('yy');axis tight
subplot(2,2,3);mesh(xx,yy,zz);
title('zzxxyy');axis tight
subplot(2,2,4);mesh(zz);
title('zz');axis tight
colormap(zeros(1,3));