restrict_dcoef.m

来自「采用matlab编写的数字图像恢复程序」· M 代码 · 共 40 行

M
40
字号
  function [dcoefxh,dcoefyh] = restrict_dcoef(dcoefxh,dcoefyh,nlevels)  %  [dcoefxH,dcoefyH] = restrict_dcoef(dcoefxh,dcoefyh,nlevels)%%  Restrict diffusion coefficient for CCFD discretization of %  the differential operator%      Lv = -div( dcoef grad u)%         = -d/dx(dcoef du/dx) - d/dy(dcoef du/dy)%  to coarse grid.   [nm1,n] = size(dcoefxh);  [tmp1,tmp2] = size(dcoefyh);    if n-1 ~= nm1    disp(' *** Error in restrict_dcoef.m. Size of dcoefxh is incorrect ***');    return  elseif tmp1-1 ~= tmp2    disp('*** Error in restrict_dcoef.m. Size of dcoefyh is incorrect ***');    return  elseif tmp1 ~= n    disp('*** Error in restrict_dcoef.m. size(dcoefxh) ~= size(dcoefyh`) ***');    return  end    if nargin == 2    nlevels = 1;  elseif log2(n) < nlevels + 1    disp(' *** Error in restrict_dcoef.m. Too many restriction levels ***');    return  end    for kk = 1:nlevels    tmp = dcoefxh(2:2:nm1,:);    dcoefxh = (tmp(:,1:2:nm1) + tmp(:,2:2:n)) / 4;    tmp = dcoefyh(:,2:2:nm1);    dcoefyh = (tmp(1:2:nm1,:) + tmp(2:2:n,:)) / 4;    n = n/2;    nm1 = n-1;  end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?