getinsertlayermatrix.m

来自「能方便的矩阵进行行列的线性扩展,并把生的矩阵存储也很方便」· M 代码 · 共 43 行

M
43
字号
%线段式插值
%By Yang zhengfa 
%2007-09-19
%out=A*[IN];IN为要进行行扩展的数据
%param specifications
%IN:   IN的行数为m
%N :   为每两行之间插n行

function a=GetInsertLayerMatrix(m,n)

onum=(m-1)*n+m;%查值后的点数
a=zeros(onum,m);
adjust=zeros(onum,m); %调整矩阵,体现重力分异作用
%每个点的权重
weight=zeros(onum,m);

for wbp=1:1:m-1;
   for wrow=1:1:n;
        weight(wbp+wrow+n*(wbp-1),wbp)=1-wrow/(n+1);
	    weight(wbp+wrow+n*(wbp-1),wbp+1)=wrow/(n+1);
       end;
   end;

%赋值约束
for i=1:1:m;
    a((n+1)*(i-1)+1,i)=1;
end;

a=a+weight+adjust;


%每行归一化 
total=0;
for grow=1:1:onum;
    for gcol0=1:1:m;
        total=total+a(grow,gcol0);
    end;
    for gcol1=1:1:m;
        a(grow,gcol1)=a(grow,gcol1)/total;
    end;
    total=0;
end;

⌨️ 快捷键说明

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