How to solve Error using + Arrays have incompatible sizes for this operation.

Hi everyone, i am trying to simulate the following function but I keep on getting the error message
Error uing + Arrays have incompatible sizes for this operation. I would be very grateful if anyone can help me solve the error. Thanks
function F = CSTR_T(x)
global F_i C_Ai T_i T_c C_A T
C_A = x(:,1);
T = x(:,2);
V = 7.929;
rho_A = 823.2;
rho_B = 1008;
C_pA = 120.7;
C_pB = 75.46;
A_o = 17000000000000;
delta_H = -90000;
UA = 360000;
E = 7236;
R = 8.314;
a(i)= F_i(i)./V;
gamma = rho_A*C_pA + rho_B*C_pB;
z = UA/(V*gamma);
b = delta_H/gamma;
F(1) = C_A - ((F_i(i)./V).*C_Ai(j)/(F_i(i)./V + A_o*exp(-E/(R*T))));
F(2) = T - ((F_i(i)./V.*T_i(k) + b*exp(-E/R*T)*C_A + (z+T_c))/(F_i(i)./V + z));
end
clear all
close all
clc
set(0,'defaultAxesFontName', 'Monospaced');
global F_i C_Ai T_i T_c C_A T
F_i = 50:0.076:80.3;
C_Ai = 0.1:0.05:20;
T_i = 20:0.2:99.7;
for i = 1:399
for j = 1:399
for k = 1:399
x0 = [0,0];
x = fsolve(@CSTR_T,x0)
end
end
end

Answers (1)

The arrays in the definition of either F(1) or F(2) (or both) are different sizes. For example:
A = 1:5;
B = 1:3;
A + B
Arrays have incompatible sizes for this operation.
If look at the line number included in the error message it will be easier to troubleshoot.
But also, I'm surprised the code you posted runs that far since you're not passing i, j, or k to the function.

Products

Release

R2021a

Asked:

on 30 Jun 2023

Commented:

on 30 Jun 2023

Community Treasure Hunt

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

Start Hunting!