下面这个代码有一些问题，第一，多重网格方法的迭代次数太多了，第二，我想画出高斯赛德尔迭代，雅克比迭代，松弛法迭代的误差随着迭代次数的变化图像，第三，我想在一张图上画出四种方法的误差随着迭代次数的变化图像，请你按照上面三个要求修改下面的代码，然后写出完整代码。clc
clear
close all

% 设置网格尺寸和大小
N = 64;
L = 1;
h = L/N;
% u是一个N+1维的方阵，用来表示二维泊松方程的数值解
u = zeros(N+1, N+1);

% 计算真实解
x=0:h:L;
y=0:h:L;
[X, Y] = meshgrid(x, y);
u_true = sin(pi * X) .* sin(pi * Y); 

[X, Y] = meshgrid(x, y);
f = 2 * pi^2 * sin(pi * X).* sin(pi * Y);

% 多重网格法
error_iteration = zeros(1,1000);
for maxnum = 1:1000
    u = V_xunhuan(u, f, h);
    % 计算误差并记录
    err = max(max(abs(u-u_true)));
    error_iteration(maxnum) = err;
    if err < 0.01
        break
    end
end

fprintf('使用多重网格法(iteration=%d)，误差为：%e\n', maxnum, err)
multi_grid_iter = maxnum;
multi_grid_error = err;

huatu_x = 1:maxnum;
huatu_y = error_iteration(1:maxnum);
figure, plot(huatu_x, huatu_y, 'r-');
title(['误差随迭代次数的变化 (多重网格法 一共迭代: ', num2str(maxnum), '次)']);
xlabel('迭代次数');
ylabel('误差');
grid on;

% 高斯赛德尔迭代(Gauss-Seidel)
u_gs = zeros(N+1, N+1);
iter = 0;
while true
    u_gs_old = u_gs;
    for i = 2:N
        for j = 2:N
            u_gs(i, j) = 0.25 * (u_gs(i+1, j) + u_gs_old(i-1, j) + u_gs(i, j+1) + u_gs_old(i, j-1) - h^2 * f(i, j));
        end
    end
    err_gs = max(max(abs(u_gs - u_true)));
    iter = iter + 1;
    if err_gs < 0.1
        break;
    end
end

fprintf('使用高斯赛德尔迭代(iteration=%d)，误差为：%e\n', iter, err_gs)

% 雅克比迭代(Jacobi)
u_j = zeros(N+1, N+1);
iter_j = 0;
while true
    u_j_old = u_j;
    for i = 2:N
        for j = 2:N
            u_j(i, j) = 0.25 * (u_j_old(i+1, j) + u_j_old(i-1, j) + u_j_old(i, j+1) + u_j_old(i, j-1) - h^2 * f(i, j));
        end
    end
    err_j = max(max(abs(u_j - u_true)));
    iter_j = iter_j + 1;
    if err_j < 0.1
        break;
    end
end

fprintf('使用雅克比迭代(iteration=%d)，误差为：%e\n', iter_j, err_j)

% 松弛法(SOR)
omega = 1.25; % 松弛因子
u_sor = zeros(N+1, N+1);
iter_sor = 0;
while true
    u_sor_old = u_sor;
    for i = 2:N
        for j = 2:N
            u_sor(i, j) = (1 - omega) * u_sor_old(i, j) + omega * 0.25 * (u_sor(i+1, j) + u_sor_old(i-1, j) + u_sor(i, j+1) + u_sor_old(i, j-1) - h^2 * f(i, j));
        end
    end
    err_sor = max(max(abs(u_sor - u_true)));
    iter_sor = iter_sor + 1;
    if err_sor < 0.1
        break;
    end
end

fprintf('使用松弛法(iteration=%d)，误差为：%e\n', iter_sor, err_sor)

% 结果输出
disp('四种方法的迭代次数：')
disp(['多重网格法: ', num2str(multi_grid_iter)])
disp(['高斯赛德尔迭代: ', num2str(iter)])
disp(['雅克比迭代: ', num2str(iter_j)])
disp(['松弛法: ', num2str(iter_sor)])

disp('四种方法的误差：')
disp(['多重网格法: ', num2str(multi_grid_error)])
disp(['高斯赛德尔迭代: ', num2str(err_gs)])
disp(['雅克比迭代: ', num2str(err_j)])
disp(['松弛法: ', num2str(err_sor)])

% 多重网格法中的相关函数
function jie = V_xunhuan(jie,f,h)
% 递归v循环
%预先平滑
jie = smoothing(jie,f,h);
%算残差
r_old = cancha(jie,f,h);
%限制
r_new = xianzhi(r_old);
%算误差
e = zeros(size(r_new));
%如果网格已经达到最粗，停止递归，否则继续递归
if length(e)-1 == 2
    e = smoothing(e,r_new,2*h);
else
    e = V_xunhuan(e,r_new,2*h);
end
% 修正
jie = jie + yantuo(e);
%后光滑
jie = smoothing(jie,f,h);
end

function res = smoothing(phi,f,h)
N = size(phi, 1) - 1;
res = phi;
for i = 2:N
    for j = 2:N
        res(i, j) = (phi(i+1, j)+res(i-1, j)+phi(i, j+1)+res(i, j-1)+h^2*f(i, j))/4;
    end
end
end

function res = cancha(phi,f,h)
N = size(phi, 1) - 1;
res = zeros(N+1, N+1);
res(2:N, 2:N) = f(2:N, 2:N)-(phi(1:N-1, 2:N)-2*phi(2:N, 2:N)+phi(3:N+1, 2:N)+phi(2:N, 1:N-1)-2*phi(2:N, 2:N)+phi(2:N, 3:N+1))/h^2;
end

function r_xi = xianzhi(r_cu)
N = (size(r_cu, 1) - 1) / 2;
r_xi = zeros(N+1, N+1);
for i = 2:N
    for j = 2:N
      r_xi(i, j) = 1/4*(r_cu(2*i-1, 2*j-1) + r_cu(2*i-1, 2*j+1) + r_cu(2*i+1, 2*j-1) + r_cu(2*i+1, 2*j+1));
    end
end
end

function e_xiwang = yantuo(e_cuwang)
    N = (size(e_cuwang, 1) - 1) * 2;  % 计算细网格的大小
    e_xiwang = zeros(N + 1, N + 1);  % 初始化细网格矩阵

    % 原有点
    for i = 1:2:N + 1
        for j = 1:2:N + 1
            e_xiwang(i, j) = e_cuwang((i + 1) / 2, (j + 1) / 2);
        end
    end

    % 横向边中点
    for i = 1:2:N+1
        for j = 2:2:N
            e_xiwang(i, j) = 1/2 * (e_cuwang((i + 1) / 2, j / 2) + e_cuwang((i + 1) / 2, (j / 2) + 1));
        end
    end

    % 纵向边中点
    for i = 2:2:N
        for j = 1:2:N+1
            e_xiwang(i, j) = 1/2*(e_cuwang(i / 2, (j + 1) / 2) + e_cuwang((i / 2) + 1, (j + 1) / 2));
        end
    end
end