Error using vertcat Dimensions of arrays being concatenated are not consistent.
1 view (last 30 days)
Show older comments
Scrip file:
timestart=0;
timeEnd=600;
timespan=[timestart timeEnd]; % Range for the independent variable time
y0= [0.67 0.1 0.01 0.71 1 1 1 0.68 0.12 0.02 0.72 ]; % assumed initial values for the compositions which are dependant variables
v=0.6; % superficial gas phase velocity in m/s
e= 0.5; % fixed bed void fraction
d=6000 ;% density of solid OSM in kg/m^3
P= 1 ;% pressure in atm
T=1073; % temperature in kelvin
R= 0.08206; % gas constant in L.atm/K.mol
M=67 ;% molar mass of solid OSM in g/mol
z2= 2 ;% lenght of the reactor in meters
z1=1;
z0=0;
[t y]=ode45(@(t,y)rxn(t,y),timespan,y0);
plot(t,y);
legend('Xa','Xb');
ylabel('species a');
xlabel('time (s)');
axis([0 600 0 1]);
title('species a with time')
function f = rxn(t,Y)
Xa=Y(1:2);
Xb=Y(3:4);
Xc=Y(5:6);
Xd=Y(7:8);
Xe=Y(9);
Xf=Y(10);
Xg=Y(11);
% parameters
v=0.6; % superficial gas phase velocity in m/s
e= 0.5; % fixed bed void fraction
d=6000 ;% density of solid OSM in kg/m^3
P= 1 ;% pressure in atm
T=1073; % temperature in kelvin
R= 0.08206; % gas constant in L.atm/K.mol
M=67 ;% molar mass of solid OSM in g/mol
z2= 2 ;% lenght of the reactor in meters
z1=z2/2;
z0=0;
% explicit equations
Ct= P/(R*T); % total gas concentration
gc=(d*(1-e))/(Ct*e);
% rate laws (assumptions used)
ra= 20;
rb=20;
rc=20;
rd=20;
re=20;
rf=200;
rg=20;
% differential equations
dXadt= (-v/e)*((Xa(1))/(z1-z0))+gc*ra % equation for gas components A
dXadt(2)= (-v/e)*((Xa(2))/(z2-z1))+gc*ra
dXbdt= (-v/e)*((Xb(1))/(z1-z0))+gc*rb % equation for gas components B
dXbdt(2)= (-v/e)*((Xb(2))/(z2-z1))+gc*rb
dXcdt= (-v/e)*((Xc(1))/(z1-z0))+gc*rc % equation for gas components C
dXcdt(2)= (-v/e)*((Xc(2))/(z2-z1))+gc*rc
dXddt= (-v/e)*((Xd(1))/(z1-z0))+gc*rd % equation for gas components D
dXddt(2)= (-v/e)*((Xd(2))/(z2-z1))+gc*rd
dXedt= M*re % equation for solid components E
dXfdt= M*rf % equation for solid components F
dXgdt= M*rg % equation for solid components G
f=[dXadt; dXbdt; dXcdt; dXddt; dXedt, dXfdt; dXgdt]
end
I'm getting the following errors and I don't understand why: I've tried everything, I think I'm not understanding a basic MATLAB concept
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in rxn (line 62)
f=[dXadt; dXbdt; dXcdt; dXddt; dXedt, dXfdt; dXgdt]
Error in rwgs>@(t,y)rxn(t,y) (line 20)
[t y]=ode45(@(t,y)rxn(t,y),timespan,y0);
0 Comments
Answers (2)
Matt J
on 30 Oct 2020
Well, for example dXadt is 1x2 and dXedt is 1x1, so you cannot stack them on top of each other to form a new matrix.
dXadt =
1.0566e+07
dXadt =
1.0e+07 *
1.0566 1.0566
dXbdt =
1.0566e+07
dXbdt =
1.0e+07 *
1.0566 1.0566
dXcdt =
1.0566e+07
dXcdt =
1.0e+07 *
1.0566 1.0566
dXddt =
1.0566e+07
dXddt =
1.0e+07 *
1.0566 1.0566
dXedt =
1340
dXfdt =
13400
dXgdt =
1340
0 Comments
See Also
Categories
Find more on Bodies 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!