Clear Filters
Clear Filters

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.

3 views (last 30 days)
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

Answers (1)

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

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!