20251117
This commit is contained in:
7
lab2/dtor.m
Normal file
7
lab2/dtor.m
Normal file
@@ -0,0 +1,7 @@
|
||||
% 度分秒转弧度
|
||||
function jrad=dtor(deg)
|
||||
degd=fix(deg);
|
||||
degf=(deg-degd)*100;
|
||||
degm=fix(degf);
|
||||
degs=(degf-degm)/36.0;
|
||||
jrad=(degd+degm*60.00+degs)*pi/180;
|
||||
25
lab2/exercise2.m
Normal file
25
lab2/exercise2.m
Normal file
@@ -0,0 +1,25 @@
|
||||
% 练习2第1-4题
|
||||
% 1
|
||||
A=[6,9,3;2,7,5];
|
||||
B=[2,4,1;4,6,8];
|
||||
A+B
|
||||
A*B
|
||||
A*B'
|
||||
|
||||
% 2
|
||||
clear
|
||||
A=[3,2,0,1,5];
|
||||
roots(A)
|
||||
|
||||
% 3
|
||||
clear
|
||||
A = [4,9,2;7,6,4;3,5,7];
|
||||
B = [37;26;28];
|
||||
A\B
|
||||
|
||||
% 4
|
||||
syms x
|
||||
f = 3*x^4-12*x^3-5*x+9;
|
||||
int (f,x)
|
||||
diff(f,x)
|
||||
int(f,x,0,2)
|
||||
BIN
lab2/exercise2.mlx
Normal file
BIN
lab2/exercise2.mlx
Normal file
Binary file not shown.
14
lab2/exercise2_5.m
Normal file
14
lab2/exercise2_5.m
Normal file
@@ -0,0 +1,14 @@
|
||||
% 练习2第五题
|
||||
subplot(1,2,1)
|
||||
t=0:0.1:2*pi;
|
||||
x=sin(3*t).*cos(t);
|
||||
y=sin(3*t).*sin(t);
|
||||
plot(x,y,'-r','Linewidth',5);
|
||||
subplot(1,2,2)
|
||||
y1=sin(x);
|
||||
y2=sin(x).*exp(-0.1*x);
|
||||
plot(x,y1,'+b',x,y2,'-g')
|
||||
title('曲线y1 y2')
|
||||
xlabel('变量x')
|
||||
ylabel('变量y')
|
||||
legend('y1','y2');
|
||||
16
lab2/exercise2_6.m
Normal file
16
lab2/exercise2_6.m
Normal file
@@ -0,0 +1,16 @@
|
||||
x=1:10;
|
||||
y=[4.9,3.3,4.2,4.2,5.7,6.5,7.7,9.4,14.7,19.0];
|
||||
a=polyfit(x,y,2);
|
||||
b=polyfit(x,y,3);
|
||||
c=polyfit(x,y,4);
|
||||
xx=1:0.1:10;
|
||||
yy1=polyval(a,xx);
|
||||
yy2=polyval(b,xx);
|
||||
yy3=polyval(c,xx);
|
||||
plot(x,y,'*b')
|
||||
hold on
|
||||
plot(xx,yy1,'-r',xx,yy2,'-g',xx,yy3,'-y')
|
||||
title('2,3,4次曲线拟合')
|
||||
xlabel('变量x')
|
||||
ylabel('变量y')
|
||||
legend('y','yy1','yy2','yy3')
|
||||
16
lab2/exercise2_7.m
Normal file
16
lab2/exercise2_7.m
Normal file
@@ -0,0 +1,16 @@
|
||||
subplot(1,2,1);
|
||||
x=-3:0.1:3;
|
||||
y=-3:0.1:3;
|
||||
z=x.*exp(-x.^2-y.^2);
|
||||
plot3(x,y,z);
|
||||
subplot(1,2,2);
|
||||
[x,y]=meshgrid(-3:0.1:3);
|
||||
z=x.*exp(-x.^2-y.^2);
|
||||
surf(x,y,z);
|
||||
shading interp;
|
||||
colormap("spring");
|
||||
k=find(x<=0 & y<=0);
|
||||
z1=z;
|
||||
z1(k)=NaN;
|
||||
surf(x,y,z1);
|
||||
shading interp;
|
||||
3
lab2/exercise2_9.m
Normal file
3
lab2/exercise2_9.m
Normal file
@@ -0,0 +1,3 @@
|
||||
axes(handles.axes1);
|
||||
[X,Y,Z]=sphere(25);
|
||||
mesh(X,Y,2*(Z+1));
|
||||
20
lab2/fn.m
Normal file
20
lab2/fn.m
Normal file
@@ -0,0 +1,20 @@
|
||||
function t=fn(n);
|
||||
m=3;
|
||||
t=1:n;
|
||||
a=1;
|
||||
j=1;
|
||||
ind=0;
|
||||
while a<n
|
||||
while j<m
|
||||
ind =ind + 1;
|
||||
if ind > length(t)
|
||||
ind=1;
|
||||
end
|
||||
j=j+1;
|
||||
end
|
||||
t(ind)=[]
|
||||
ind=ind-1;
|
||||
j=1;
|
||||
a=a+1;
|
||||
end
|
||||
t
|
||||
10
lab2/pmzbfs.m
Normal file
10
lab2/pmzbfs.m
Normal file
@@ -0,0 +1,10 @@
|
||||
function [raf,jl]=pmzbfs(x1,y1,x2,y2)
|
||||
detx=x2-x1;dety=y2-y1;
|
||||
faw1=atan(dety/detx);
|
||||
j1=sqrt(detx*detx+dety*dety);
|
||||
if detx<0
|
||||
raf=faw1+pi;
|
||||
end
|
||||
if (detx>0)*(det<0)
|
||||
raf=faw1+2*pi;
|
||||
end
|
||||
7
lab2/rad2deg.m
Normal file
7
lab2/rad2deg.m
Normal file
@@ -0,0 +1,7 @@
|
||||
function jdeg=rad2deg(rad)
|
||||
rad=rad*180/pi;
|
||||
deg=fix(rad);
|
||||
xsbf=(rad-deg)*60;
|
||||
degf=fix(xsbf);
|
||||
degm=(xsbf-degf)*60;
|
||||
jdeg=deg+degf/100.0+degm/10000.0;
|
||||
Reference in New Issue
Block a user