Matlab期末复习
一,《MATLAB》往年试卷
clear
syms x m n y j k
f = m*x^3 + n* y^2+j*x+k;
diff(f,'x',2);
diff(f,'y',2);
int(f,y);
int(f,y,0,1);
limit(f,y,1.1)
clear
syms x k
y1 = 1/k^2;
y2 = x^k;
sum1= symsum(y1,k,1,inf);
sum2 = symsum(y2,k,0,inf)
clear
A = zeros(5);
B = ones(8)
C = magic(5)
I = eye(6)
D = diag([-1,-1,-1,-1,-1,-1,-1])
S = D +1
clear
syms x
y1=sin(3*x)*cos(2*x);
y2=0.3*x+1;
subplot(1,2,1);
ezplot(x,y1);
title('y = sin(3*x)*cos(2*x)');
xlabel('x');
ylabel('y');
grid on
subplot(1,2,2);
ezplot(x,y2);
title('y =0.3*x+1;');
xlabel('x');
ylabel('y');
grid on
clear
[x,y] = meshgrid(-2:0.1:2)
z = (x.^2).*(exp(-(x.^2+y.^2)));
subplot(1,2,1);
mesh(x,y,z);
title('三维网线图')
xlabel('x');
ylabel('y')
zlabel('z')
subplot(1,2,2);
surf(x,y,z);
title('三维(透视)网格曲面')
xlabel('x');
ylabel('y')
zlabel('z')
5.有矩阵A = [1,3,2; 4,6,5; 7,9,8],取出该矩阵的第一、二、五个元素,用该矩阵作为基本单元成形一个6×9的大矩阵B,大矩阵B以矩阵A为基本单位形成2×3的阵列,找出B中大于5的元素的单下标和全下标。将矩阵B顺时针旋转180度变为矩阵C,将矩阵C的左右两部分以中心为轴进行交换变为矩阵D,将矩阵D变形为9×6的矩阵E。删除矩阵E中的第2行变为矩阵F(20
clear
A = [1,3,2; 4,6,5; 7,9,8]
A(A==1)=0;
A(A==4)=0;
A(A==6)=0;
B=repmat(A,2,3)
find(B>5)
C = rot90(B,-2)
D = fliplr(C)
E = reshape(D,9,6)
E(2,:)= [];
F = E;
function y=f(x)
if x<=-1
y=0.4.*x;
elseif x>-1 & x<=4
y=1.5-0.3.*x;
else
y=0.6;
end
end
x=0:0.01:2;
y=f(x).*f(x+2);
plot(x,y)
grid on