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.

1 次查看(过去 30 天)
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

回答(1 个)

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

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by