Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-14.

2 Ansichten (letzte 30 Tage)
My code is coming up with an error saying "Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-14." on the line highlighted by the asterix but the workspace shows that the variables P9 and z are both 1 x 14. the beginning of the if loop works, produces a 1 x 14 matrix with the first 2 cells populated by Pa and the remainder with zeros due to the error.
for i=1:14
if x(1,i) < Pcrit_c
P9(1,i) = Pa;
T9s = To5.*(P9./Po5).^((gamma_g-1)/gamma_g);
T9 = eta_n*(T9s-To5)+To5;
V9 = sqrt(2*Cp_g*1000*(To5-T9));
else
**** P9(1,i) = z;**** < this line
T9s = To5*(P9/Po5)^((gamma_g-1)/gamma_g);
T9 = eta_n*(T9s-To5)+To5;
V9 = sqrt(gamma_g*R*1000*T9);
end
end

Antworten (1)

Sreelakshmi S.B
Sreelakshmi S.B am 8 Mär. 2019
P9 might be of size 1x14 but you're assigning z (of size 1x14) to P9(1,i) which is of size 1

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by