1.随机产生一个10×10的矩阵,矩阵元素为0~10之间的数;对每列求均值产生一个均值行向量;求矩阵的秩,判断是否为可逆阵,在可逆的情况下求解逆矩阵,并验证逆矩阵的正确性,即判断两个矩阵的乘积是否为单位阵。
clear all; close all; A = rand(10,10)*10 B = inv(A) disp('The A*B equals to :'); disp(A*B); fprintf('sure det(A * B) == %f',det(A*B)); C = det(A*B)
2. 将表达式\((x-4)(x+5)(x^2-6x+9)\)展开为多项式形式,并求其对应的一元n次方程的根。
clear all; close all; a = [1 -6 9]; b = [0 1 5]; c = [0 1 -4]; d = conv(conv(a,b),c) disp('The roots is :'); AN = roots(d); len = length(AN); for i = 1:len fprintf('X%d = %3f\n',i,AN(i)); end
3. 将有理分式进行部分分式展开:\(H(s) = \displaystyle\frac{2s^2+2s+13}{(s+1)(s-2)(s-3)}\)
clear all; close all; n = [2 2 13]; p1 = [0 1 1]; p2 = [0 1 -2]; p3 = [0 1 -3]; r = [-1 2 3]; p = poly(r) [above,below,mul] = residue(n,p)
4. 利用符号函数绘制信号\(f_1(t)=\displaystyle\frac{sin(\omega_0(t-t_0))}{\omega_0t}\), \(f_2(t) = \displaystyle\frac{sin\omega_0(t-t_0)}{\omega_0(t-t_0)}\),\(f(t) = f_1(t)+f_2(t)\)
OmigaSet = [2:3:15]; t = sym('t'); Omiga = sym('Omiga'); f1 = sym('sin(Omiga*t)/(Omiga*t)'); f2 = sym('sin(Omiga*(t-3))/(Omiga*(t-3))'); for i = 1:length(OmigaSet) Plotf1 = subs(f1,Omiga,OmigaSet(i)); Plotf2 = subs(f2,Omiga,OmigaSet(i)); subplot(2,2,1),h1 = ezplot(Plotf1); xlim([-3,7]); ylim([-.5,1.5]); subplot(2,2,2),h2 = ezplot(Plotf2); xlim([-3,7]); ylim([-.5,1.5]); subplot(2,2,[3 4]),h3 = ezplot(Plotf1 + Plotf2); xlim([-3,7]); ylim([-.5,1.5]); set([h1,h2,h3],'LineWidth',1); title('Superposition Of two figure above'); scrsz = get(0,'ScreenSize'); set(gcf,'Position',scrsz); saveas(gcf,['Item2_4_' num2str(i) '.png']); end