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