I am getting error with"Matrix dimensions must agree" for following code,please let me know where I am doing wrong?

1 vue (au cours des 30 derniers jours)
function xdot = cstr11(t,x)
global u
global qif
% Input (1)
% Coolant Flow rate
Qc = u;
% States (2)
% Concentration of A in the reactor (mol/L)
T = x(1,1)
% Temperature of reactor fluid (deg K)
CA = x(2,1)
% Process Parameters
% Product flow rate lit/min
qif = 100;
% Input product concentration mol/lit
cif = 1;
% Input temperature K
tif=350;
% Coolant Temperature K
tcf=350;
% Container volume lit
v=100;
% Activation energy term K
EoverR=10^4;
% Reaction rate constant 1/min
k0=7.2*10^10;
% % % Plant constant
k1=1.44e13; %K lit/min/mol
k2=0.01; %1/lit
k3=700;%lit/min
% Plant constant (Manimozhi)
% % k1=1.44*10^13; %K lit/min/mol
% % k2=1; %1/lit
% % k3=700;%lit/min
% State equations
%Tdot
xdot(1,1)=qif*(tif-T)/v + k1*CA*(exp(-EoverR/T)) + k2*Qc*(1-(exp(-k3/Qc)))*(tcf-T);
%Cdot
xdot(2,1)=qif*(cif-CA)/v - k0*CA*(exp(-EoverR/T));
Command Window error message for cstr11(0,[20;100]) is Error using / Matrix dimensions must agree.
Error in cstr11 (line 45) xdot(1,1)=qif*(tif-T)/v + k1*CA*(exp(-EoverR/T)) + k2*Qc*(1-(exp(-k3/Qc)))*(tcf-T);
Please let me know where I am doing wrong? Awaiting your response. Thank You.

Réponse acceptée

Alexandra Harkai
Alexandra Harkai le 29 Nov 2016
The problem is here:
k3/Qc
Looks like Qc gets its value from global variable u which seems to be a non-scalar. So it can't perform the division you ask for. If you want an element-wise division, you can use
k3./Qc
or
k3\Qc
to mutliply with the matrix inverse of Qc.
  4 commentaires
Karan Gill
Karan Gill le 29 Nov 2016
Try searching for the error. This is a common error and there are several threads on how to fix it.
Alexandra Harkai
Alexandra Harkai le 29 Nov 2016
Even though Qc is defined in the main function you set Qc = u in this cstr11 function so Qc will be whatever u is (for the scope of this function).

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by