Matlab错误:赋值的非单例rhs维度比非单例下标多

Matlab错误:赋值的非单例rhs维度比非单例下标多,matlab,pde,heat,Matlab,Pde,Heat,我正在编写这个函数。运行函数时出现此错误 赋值的非单例rhs维度多于非单例下标。 我不明白哪里出错了 Lx = r; Ly = z; Nx = 20; Ny = Nx; dx = Lx/Nx; dy = Ly/Ny; k = 0.72; rho = 1920; %

我正在编写这个函数。运行函数时出现此错误

赋值的非单例rhs维度多于非单例下标。 我不明白哪里出错了

Lx = r;                
Ly = z;                

Nx = 20;                
Ny = Nx;                

dx = Lx/Nx;            
dy = Ly/Ny;            


k = 0.72;             
rho = 1920;             % Density (kg/m^3)
Cp = 835;               % Specific heat (J/kgK)
alpha = k/(rho*Cp);     % Thermal diffusivity (m^2/s)

deltaT = 1300;                          % Time step (seconds)
deltaT_stable_max = .25*dx.^2/alpha;     % Maximum stable time step
Fo = alpha*deltaT./dx.^2;                 % Fourier number 

T=(21:0.1:35)
T1 = T;                 % BC temperature 1 (deg. Celsius)
T2(1) = T(1);               % BC temperature 2 (deg. Celsius)

T = T1 %.*ones(Nx+1,Ny+1); % Initialize T array to T1 everywhere
T(1:Nx,Ny+1) = T2;      % Initialize top row to T2 boundary condition
T(1,Ny+1) = T2;      % Initialize top left
T(Nx+1,Ny+1) = T2;      % Initialize top right
Tplot = ones(Lmax,1);   % Initialize Tplot to allocate memory

x = 0:dx:Lx;            % Create x-distance node locations
y = 0:dy:Ly;            % Create y-distance node locations

for L = 1:Lmax          % Loop through time steps
    Told = T;           % Store previous T array as Told for next time step
    for j = 2:length(h)        % Loop through rows
        for i = 2:length(h)    % Loop through columns
            T2(i,j) = Fo*(Told(i-1,j) + Told(i+1,j) + Told(i,j-1)+ Told(i,j+1)) + (1-4*Fo)*Told(i,j);
        end   
    end
end

谢谢

请提供一个。MATLAB还会告诉您出现故障的线路号。你的代码也有很多错误,比如没有定义变量。请确保这些琐碎的错误已经消失。@Elly T2(i,j)=Fo*(告诉(i-1,j)+告诉(i+1,j)+告诉(i,j-1)+告诉(i,j+1))+(1-4*Fo)*告诉(i,j);