rectgrid.m

来自「有监督自组织映射-偏最小二乘算法(A supervised self-organ」· M 代码 · 共 36 行

M
36
字号
function [Neighbours, WeightValues] = RectGrid(Radius,Winner,MLKP);

if (Radius == 0)
    Neighbours=[1 Winner];
    WeightValues=1;
else
    NeighbourFunction=upper(MLKP.NeighbourFunction);
    if (NeighbourFunction == 'MEX' | NeighbourFunction == 'GAU')
        XArr=(0:1:Radius)/Radius;
        if (NeighbourFunction == 'MEX')
            for i=1:Radius+1
                MexHat(i)=2*exp(-2.5*XArr(i)^2)-exp(-6*(XArr(i)-0.5)^2);
            end
        else
            for i=1:Radius+1
                MexHat(i)=exp(-XArr(i)^2);
            end
        end
        MexHat=MexHat/max(MexHat);
    elseif (NeighbourFunction == 'BLK')
        MexHat(1:Radius+1)=1;
    else
        MexHat=1-(0:Radius)/(Radius+1);
    end
    ind=0;
    Crow=floor((Winner-1)/MLKP.Ncol)+1;
    Ccol=Winner-(Crow-1)*MLKP.Ncol;
    for irow=max(1,Crow-Radius):min(MLKP.Nrow,Crow+Radius)
        for icol=max(1,Ccol-Radius):min(MLKP.Ncol,Ccol+Radius)
            ind=ind+1;
            Neighbours(ind)=(irow-1)*MLKP.Ncol+icol;
            WeightValues(ind)=MexHat(1+max(abs(irow-Crow),abs(icol-Ccol)));
        end
    end
end

⌨️ 快捷键说明

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