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

1 visualización (últimos 30 días)
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;
  2 comentarios
Andrés Castro
Andrés Castro el 27 de Feb. de 2020
Hi Alexandra:
In your code you have a mistake in su variable. The variable T is unrecognized. For this reason when you want to compute D(1), it isn't allowed.
Regards!

Iniciar sesión para comentar.

Respuestas (1)

Jeremy
Jeremy el 27 de Feb. de 2020
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;

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by