Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 10-by-10. not sure why i am getting this error

6 views (last 30 days)
data_rho = [7840,0.44];
data_Cp = [490,0.0733333];
data_k = [13.1947,0.0126919];
%% Geometry
L = 0.03;
%% Boundary conditions
T0 = 1000;
Tinfinity = 20 + 273;
htc_top = 50;
htc_sides = 100;
htc_btm = 20;
Emissivity = 0.0;
time = 0;
%% thermocouple positions
tpx = [0.015 0.027 0.027];
tpy = [0.015 0.015 0.027];
%% Simulation control
n = 10;
CFL = 0.5;
itPlot = 10;
%% Discretize space
dx = L/(n-1);
x = 0:dx:L;
y = L:-dx:0; % T(1,1) is the top left
%% Initialize variables
T = ones(n,n)*T0;
T_new = zeros(n,n);
dtMat = zeros(n,n);
it = 0;
%% Physical constants
stefan = 5.670367e-8;
%% Record predictions
Temp_thermocouples = interp2(x,y,T,tpx,tpy);
SaveNumber = 1;
TimeVector(SaveNumber) = time;
TempSavedMatrix(SaveNumber,:) = Temp_thermocouples;
%% Model calculation
while max(max(T)) > 300 + 273.15
%% Thermophysical properties
rho = data_rho(1) + data_rho(2)*T;
k0 = data_k(1) + data_k(2)*T;
Cp = data_Cp(1) + data_Cp(2)*T;
%% Calculate temperature dependent parameters
alpha = k0./rho./Cp;
Br = stefan*Emissivity*dx./k0;
Biot_top = htc_top*dx./k0;
Biot_btm = htc_btm*dx./k0;
Biot_sides = htc_sides*dx./k0;
%% time step
for i = 2: n-1
for j = 2: n-1
dtMat(i,j) = CFL*dx*dx/4./alpha(i,j);
end
end
% top left
dtMat(1,1) = CFL*dx*dx/2./alpha(1,1)*(Biot_sides(1,1)+Biot_top(1,1)+2*Br(1,1)*T(1,1)^3);
% top edge
for j = 2: n-1
dtMat(1,j) = CFL*dx*dx/2./alpha(1,j)*(2+Biot_top+Br(1,j)*T(1,j)^3);
end
line with the error code is
for j = 2: n-1
dtMat(1,j) = CFL*dx*dx/2./alpha(1,j)*(2+Biot_top+Br(1,j)*T(1,j)^3);
end

Accepted Answer

Daniel Pollard
Daniel Pollard on 4 Feb 2021
Edited: Daniel Pollard on 4 Feb 2021
Biot_top is size 10x10. dtMat(1,j) is size 1x1. This means the LHS of your line is 1x1, and the RHS is 10x10, so you can't make the assignment.
I suspect you intended to write Biot_top(1,j)?

More Answers (0)

Categories

Find more on Dynamic System Models in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!