function [K, L] = extract_mph_Matrice(model, solnum)

%选择想要提取的解
str_sol = sprintf('sol%d', solnum);

% 直接从COMSOL提取解
model.sol(str_sol).runAll;
U = mphgetu(model,'solnum',solnum);

% 从COMSOL提取刚度矩阵K, 载荷向量L
mphproc = mphmatrix(model, str_sol, 'out',{'K','L'},'complexfun','on');

% 验证提取的刚度矩阵K, 载荷向量L求出的X与COMSOL求解的U是否一致
tic
X = mphproc.K\mphproc.L;
toc
tol = norm(X-U);

% 检测误差是否符合要求
if tol<1
    K = mphproc.K;
    L = mphproc.L;
    % 提取刚度矩阵K的稀疏矩阵特征
else
    % 如果误差过大考虑是否是刚度矩阵K, 载荷向量L有问题
    disp("直接提取刚度矩阵, 载荷向量有问题, 考虑他们的消去形式: ")
    mphproc = mphmatrix(model, str_sol, 'out', ...
    {'Null','ud','Kc','Lc'},'complexfun','on');

    K = mphproc.Kc;
    L = mphproc.Lc;
    Xn = K\L;
    Xc = mphproc.ud + mphproc.Null * Xn;

    fprintf('消去矩阵求解的误差是%2f\n', norm(Xc-U));
end

end