如何修复“ Submatrix定义错误”错误?

时间:2019-06-08 04:34:18

标签: matrix scilab

我一直在尝试运行一个循环,在每次迭代中为矩阵分配值。每个涉及的矩阵均为10x10尺寸。但是,Scilab显示“子矩阵定义错误”错误。代码如下:

for t = 0:dt:time
    for j = 2:9
        for i = 2:9
            a(i,j)= (k*delX)/dx;
            b(i,j)= (2*(k*delX)/dx) + (2*(k*delY)/dx) + ((rho*c*delX*delY)/delT);
            c(i,j)= (k*delX)/dx;
            d(i,j)= ((k*delX)/dx)*T_new(i,j-1)+((k*delX)/dx)*T_new(i,j+1)+(rho*c*delX*delY*T_old(i,j))/delT;

            if i==2
                {
                  A(i,j)= c(i,j)/b(i,j);
                  B(i,j)= d(i,j)/b(i,j);
                }
            else
                {
                    A(i,j)= c(i,j)/(b(i,j)-a(i,j)*A(i-1,j));
                    B(i,j)= (A(i,j)*B(i-1,j)+d(i,j))/(b(i,j)-a(i,j)*A(i-1,j));
                }
            end
        end

        for i = 9:1
            T_new(i,j)= A(i,j)*T_new(i+1,j)+B(i,j);
        end

    end
   T_old = T_new;
end

获得的错误如下:

)*T_new(i,j+1)+(rho*c*delX*delY*T_old(i,j))/delT
                                              !--error 15 
Submatrix incorrectly defined.
at line      47 of exec file called by :    
exec('C:\Users\nEW u\Documents\SciLab 2D program Set\2D_trial1.sce', -1)

0 个答案:

没有答案