MATLAB: Left and right sides have a different number of elements

code errorMATLAB

Getting error with this line, please advise,
Thanks!
dA(i)=(rate_a(i).*F.*Q)-(rate_b(i).*F.*L)-(rate_c(i).*F);
left and right sides have a different number of elements

Best Answer

My guess is that ‘A’, ‘B’ and ‘C’ are vectors, or you would not be subscripting them.
You need to subscript them here as well:
dA(i)=(rate_a(i).*A.*B)-(rate_b(i).*A.*C)-(rate_c(i).*A);
dB(i)=(rate_b(i).*A.*C)-(rate_a(i).*A.*B)-(rate_d(i).*B);
dC(i)=rate_d(i).*B;
or you will continue to have a dimension mismatch.