Unable to perform assignment because the left and right sides have a different number of elements.

1 次查看(过去 30 天)
When the code is run, this error generates:
>> twentycells
Unable to perform assignment because the left and
right sides have a different number of elements.
Error in twentycells (line 34)
D(1) = U-su;
I attached the codes below to assist in debunking the error.
Thank you in advance!
% name constant inputs:
ncells = 20;
hin = 50;
hinz = 100;
Tin = 100;
Tinz = 200;
Diam = 0.08;
L = 1;
k = 100;
P = pi*Diam;
Ac = (pi/4)*Diam.^2;
% calculate delta x (DX)
DX = L/ncells;
% mark cell centers
X(1) = 0;
for i = 2:ncells
X(i) = X(i-1) + DX;
end
% seperate math eqns to make coefficient calculations easier
Z = k/DX;
Y = (hinz*DX)/2;
W = k+Y;
V = (hinz*k)/W;
U = -V*Tinz;
sp = -hin*P*DX/Ac;
su = hin*P*T*DX/Ac;
% tridiagonal coefficients at left and right B/C's
B(1) = -Z-V+sp;
C(1) = Z;
D(1) = U-su;
A(ncells) = Z;
B(ncells) = -Z+sp;
D(ncells) = -su;

回答(1 个)

Jeremy
Jeremy 2020-2-27
Where is the definition of T? I am guessing that T is a vector, which makes su = hin*P*T*DX/Ac; a vector, and then you're trying to assign a vector to a scalar value with D(1) = U-su;

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by