the last commit for lab6 exercises and a2 exercises
This commit is contained in:
9
a2_1_1.m
Normal file
9
a2_1_1.m
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
% 学号为24110901003
|
||||||
|
% 学号最后的非零第一位、二位数字,u=
|
||||||
|
u=3;
|
||||||
|
v=1;
|
||||||
|
% 因为比较复杂,将分子分母分开计算
|
||||||
|
m=(exp(u)+v)^2;
|
||||||
|
n=v^2-u;
|
||||||
|
result=m/n;
|
||||||
|
disp(result)
|
||||||
9
a2_1_2.m
Normal file
9
a2_1_2.m
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
% 学号为24110901003
|
||||||
|
% 学号最后的非零第一位、二位数字,u=3,v=1;
|
||||||
|
u=3;
|
||||||
|
v=1;
|
||||||
|
% 因为比较复杂,将分子分母分开计算
|
||||||
|
m=sqrt(u-3*v);
|
||||||
|
n=u*v;
|
||||||
|
result=m/n;
|
||||||
|
disp(result);
|
||||||
2
a2_3.m
Normal file
2
a2_3.m
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
A=[3,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,7];
|
||||||
|
B=sprank(A)
|
||||||
5
a2_5.m
Normal file
5
a2_5.m
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
% 24110901003
|
||||||
|
a=3;
|
||||||
|
b=a>5 % 表达式值为0
|
||||||
|
a(b)=sqrt(a(b)) % 值为3
|
||||||
|
a(~b)=a(~b).^2 % 值为9
|
||||||
16
a2_6.m
Normal file
16
a2_6.m
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
% 学号24110901003
|
||||||
|
% a=3,b=1,c=9;
|
||||||
|
a=3;
|
||||||
|
b=1;
|
||||||
|
c=9;
|
||||||
|
% 定义x
|
||||||
|
syms x
|
||||||
|
% 方程表达式
|
||||||
|
f=a*x^2+b*x+c;
|
||||||
|
% 用solve函数来解
|
||||||
|
solve(f==0)
|
||||||
|
% 输出如下
|
||||||
|
% ans =
|
||||||
|
%
|
||||||
|
% - (107^(1/2)*1i)/6 - 1/6
|
||||||
|
% (107^(1/2)*1i)/6 - 1/6
|
||||||
10
b3_5.m
Normal file
10
b3_5.m
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
% c取值为学号最后的非零第一位数字
|
||||||
|
c=3
|
||||||
|
switch (c)
|
||||||
|
case {1, 3, 5, 7, 9},
|
||||||
|
disp('The value is odd.');
|
||||||
|
case {2, 4, 6, 8, 10},
|
||||||
|
disp('The value is even.');
|
||||||
|
otherwise
|
||||||
|
disp('The value is out of range.');
|
||||||
|
end
|
||||||
13
b4_3.m
Normal file
13
b4_3.m
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
% 定义x,y
|
||||||
|
x=6
|
||||||
|
y=6
|
||||||
|
if (x>=0 && y>=0)
|
||||||
|
r=x+y
|
||||||
|
elseif (x>=0 && y<0)
|
||||||
|
r=x+y^2;
|
||||||
|
elseif (x<0 && y>=0)
|
||||||
|
r=x^2+y;
|
||||||
|
elseif (x<0 && y<0)
|
||||||
|
r=x^2+y^2;
|
||||||
|
end
|
||||||
|
disp(x)
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function jrad=deg2rad(deg)
|
function jrad=deg2rad(deg)
|
||||||
degd=fix(deg);
|
degd=fix(deg);
|
||||||
degf=(deg-degd)*100;
|
degf=(deg-degd)*100;
|
||||||
degm=fix(degf);
|
degm=fix(degf);
|
||||||
degs=(degf-degm)/36.0;
|
degs=(degf-degm)/36.0;
|
||||||
jrad=(degd+degm/60.00+degs)* pi / 180.0;
|
jrad=(degd+degm/60.00+degs)* pi / 180.0;
|
||||||
4
lab6/exercise6_1.m
Normal file
4
lab6/exercise6_1.m
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
A=[0,9,6;1,3,0];
|
||||||
|
B=[1,4,3;1,5,0];
|
||||||
|
A&B
|
||||||
|
A./B
|
||||||
3
lab6/exercise6_10.m
Normal file
3
lab6/exercise6_10.m
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
syms x;
|
||||||
|
eq1=x^4-4*x^3+12*x-9==0;
|
||||||
|
x=solve(eq1,x)
|
||||||
8
lab6/exercise6_8.m
Normal file
8
lab6/exercise6_8.m
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
for k=1:10
|
||||||
|
if k>6
|
||||||
|
break
|
||||||
|
else
|
||||||
|
arry(k)=k;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
disp(arry);
|
||||||
7
lab6/exercise6_9.m
Normal file
7
lab6/exercise6_9.m
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
i=2;
|
||||||
|
a=2i;
|
||||||
|
b=2*i;
|
||||||
|
c=2*sqrt(-1);
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
4
lab6/exercise6_c_1.m
Normal file
4
lab6/exercise6_c_1.m
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
A=[1,2,3;4:6;7:9];
|
||||||
|
C=[A;[10,11,12]];
|
||||||
|
D=C(1:3,[2,3]);
|
||||||
|
E=C(2,[1,2]);
|
||||||
9
lab6/exercise6_c_2.m
Normal file
9
lab6/exercise6_c_2.m
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
x=[0,1,0,2,0,3,0,4];
|
||||||
|
for k=1:8
|
||||||
|
if x(k)==0
|
||||||
|
x(k)=k;
|
||||||
|
else
|
||||||
|
x(k)=2*k+1;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
disp(x)
|
||||||
3
lab6/exercise6_c_3.m
Normal file
3
lab6/exercise6_c_3.m
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
syms a b c x;
|
||||||
|
s=a*x^2+b*x+c;
|
||||||
|
solve(s)
|
||||||
3
lab6/exercise6_c_4.m
Normal file
3
lab6/exercise6_c_4.m
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
A=[2,3,1,2;1,3,0,1;1,-1,1,8;7,1,-2,2];
|
||||||
|
B=[8,6,1,5];
|
||||||
|
A\B'
|
||||||
7
lab6/exercise6_c_5.m
Normal file
7
lab6/exercise6_c_5.m
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
t=linspace(0,2*pi,50);
|
||||||
|
y1=sin(2.*t-0.3);
|
||||||
|
y2=3.*cos(t+0.5);
|
||||||
|
plot(t,y1,'-.ro');
|
||||||
|
hold on
|
||||||
|
plot(t,y2,':b*');
|
||||||
|
hold off
|
||||||
8
lab6/exercise6_d.m
Normal file
8
lab6/exercise6_d.m
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
for i=100:999
|
||||||
|
a=fix(i/100); % 取百位
|
||||||
|
b=rem(fix(i/10),10); % 取十位
|
||||||
|
c=rem(i,10); % 取个位
|
||||||
|
if a^3+b^3+c^3==i
|
||||||
|
disp(i);
|
||||||
|
end
|
||||||
|
end
|
||||||
11
lab6/lab6.m
Normal file
11
lab6/lab6.m
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[F,P]=uigetfile('*.pgm;*.jpg;*.jpeg;*.tif;*.tiff;*.bmp;*.png;*.hdf;*.pcx;*.xwd','选择图像');
|
||||||
|
imna=strcat(P,F);
|
||||||
|
myi=imread(imna);
|
||||||
|
figure(1);
|
||||||
|
imshow(myi);
|
||||||
|
figure(2);
|
||||||
|
image(myi);
|
||||||
|
bgray=rgb2gray(myi);
|
||||||
|
figure(3);
|
||||||
|
imshow(bgray);
|
||||||
|
imwrite(bgray,'th.bmp','bmp');
|
||||||
BIN
lab6/th.bmp
Normal file
BIN
lab6/th.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 MiB |
BIN
lab6/屏幕截图 2025-10-26 085153.png
Normal file
BIN
lab6/屏幕截图 2025-10-26 085153.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
3
untitled.m
Normal file
3
untitled.m
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
A=ones(5,4);
|
||||||
|
size(A)
|
||||||
|
zeros(size(A))
|
||||||
4
untitled12.m
Normal file
4
untitled12.m
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
A=[4,5];
|
||||||
|
B=[9,3];
|
||||||
|
% 计算两点间距离
|
||||||
|
distance=(A(1,1)-B(1,1))^2+(A(1,2)-B(1,2)^2)
|
||||||
9
untitled13.m
Normal file
9
untitled13.m
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
% 学号为24110901003
|
||||||
|
% 学号最后的非零第一位、二位数字,u=3,v=1;
|
||||||
|
u=3;
|
||||||
|
v=1;
|
||||||
|
% 因为比较复杂,将分子分母分开计算
|
||||||
|
m=sqrt(u-3*v);
|
||||||
|
n=u*v;
|
||||||
|
result=m/n;
|
||||||
|
disp(result);
|
||||||
19
untitled4.m
Normal file
19
untitled4.m
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
% 建立系数矩阵
|
||||||
|
A=[-2.0,5.0,1.0,3.0,4.0,-1.0;...
|
||||||
|
2.0,-1.0,-5.0,-2.0,6.0,4.0;...
|
||||||
|
-1.0,6.0,-4.0,-5.0,3.0,-1.0;...
|
||||||
|
4.0,3.0,-6.0,-5.0,-2.0,-2.0;...
|
||||||
|
-3.0,6.0,4.0,2.0,-6.0,4.0;...
|
||||||
|
2.0,4.0,4.0,4.0,5.0,-4.0];
|
||||||
|
B=[0.0;1.0;-6.0;10.0;-6.0;-2.0];
|
||||||
|
%直接用左除的方式得到结果
|
||||||
|
A\B
|
||||||
|
% 以下是运行结果
|
||||||
|
% ans =
|
||||||
|
%
|
||||||
|
% 0.6626
|
||||||
|
% -0.1326
|
||||||
|
% -3.0137
|
||||||
|
% 2.8355
|
||||||
|
% -1.0852
|
||||||
|
% -0.8360
|
||||||
16
untitled6.m
Normal file
16
untitled6.m
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
% a取值为3
|
||||||
|
a=3;
|
||||||
|
A=randn(a)
|
||||||
|
% 求行列式的值
|
||||||
|
det(A)
|
||||||
|
|
||||||
|
% A =
|
||||||
|
%
|
||||||
|
% 0.7172 1.0347 0.2939
|
||||||
|
% 1.6302 0.7269 -0.7873
|
||||||
|
% 0.4889 -0.3034 0.8884
|
||||||
|
%
|
||||||
|
%
|
||||||
|
% ans =
|
||||||
|
%
|
||||||
|
% -1.8548
|
||||||
0
untitled9.m
Normal file
0
untitled9.m
Normal file
Reference in New Issue
Block a user