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

时间:2018-04-19 12:48:42

标签: matlab pde heat

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

分配比非单例下标具有更多非单例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

谢谢

0 个答案:

没有答案