How to solve " Error using vertcat Dimensions of arrays being concatenated are not consistent " problem ?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Golam
el 7 de Feb. de 2024
Comentada: Golam
el 7 de Feb. de 2024
I am getting "Error using vertcat Dimensions of arrays being concatenated are not consistent" error for the following code. Would anyone please help me find what is the problem here and how to fix it please.
clc
clear
close all
T_ar=300; % Temparature of Argon gas
n=1.72e16; % plasma density in m^-3
m_e=9.109e-31; % mass of an electron in kg
e=1.60217663e-19; % electronic charge in Coulomb
epsilon=8.854e-12; % permittivity of free space in F*m^-1
A_sp=0.00502656; % Powered Electrode Area in m^2 (4 cm radious)
A_sg=0.007854; % Grounded Electrode Area in m^2 (5 cm radious)
lp=0.06; % plasma bulk length in m
T_e=2.64; % Electron Temparature in eV
p=60*10^-3; % pressure in Torr
n_g=3.3*10^22*p; % gas density in m^-3
Km=10^-13; % rate coefficient
v_m=Km*n_g; % momentum transfer collision frequency
k_B=1.380649e-23; % Boltzmann's Constant in J/K
v_e = sqrt(8*e*T_e/(pi*m_e)); % mean thermal speed
v_eff=v_m+((v_e)/lp); % effective collision frequency
m_i=40; % Argon mass in amu for determining bohm velocity
amu=1.660539e-27; % 1 Dalton
v_B=sqrt((e*T_e)/(m_i*amu)); % Bohm velocity
xx1=(1/(2*e*epsilon*n*A_sp^2));
xx2=(1/(2*e*epsilon*n*A_sg^2));
xx3=(1/(2*e*epsilon*n*A_sp^2*T_e));
xx4=(1/(2*e*epsilon*n*A_sg^2*T_e));
Lp= (lp*m_e)/(e^2*n*A_sp); % Plasma Bulk Inductance
Lp_inv=1/Lp;
J_e=e*n*v_e; % Coefficient of electron current
J_i=e*n*v_B; % Coefficient of ion current
Jip=J_i*A_sp; % Ion current at Powered Sheath
Jig=J_i*A_sg; % Ion current at Grounded Sheath
Jep=J_e*A_sp;
Jeg=J_e*A_sg;
V0=300; % Amplitude of RF input voltage
C_B=3.34e-6; % Dc blocking capacitor
Cb_inv=1/C_B;
f = @(t,x) [-(x(4))-(Jip) + (Jep.*exp(-(xx1.*(x(1)^2))));
(x(4))-(Jig) + (Jeg.*exp(-(xx2.*(x(2)^2))));
-(Cb_inv.*(x(4)));
(V0.*cos(t).*(Lp_inv))+(xx3.*(x(1)^2).*(Lp_inv))-(xx4.*(x(2)^2).*(Lp_inv))+(x(3).*(Lp_inv)) -(v_eff.*(x(4)))];
options = odeset('RelTol',1e-4,'AbsTol',1e-6);
[t,xa] = ode45(f,[0, 80],[0,0,-62,0],options);
figure(1)
plot(t,xa(:,1),'Color','blue')
title('xa1')
xlabel('t'), ylabel('Qsp (Powered Electrode Sheath Charge)')
grid on
figure(2)
plot(t,xa(:,2),'Color','blue')
title('xa2')
xlabel('t'), ylabel('Qsp (Grounded Electrode Sheath Charge)')
grid on
figure(3)
plot(t,xa(:,3),'Color','blue')
title('xa3')
xlabel('t'), ylabel('Self Bias Voltage')
grid on
figure(4)
plot(t,xa(:,4),'Color','blue')
title('xa4')
xlabel('t'), ylabel('Plasma Current')
grid on
0 comentarios
Respuesta aceptada
Stephen23
el 7 de Feb. de 2024
Editada: Stephen23
el 7 de Feb. de 2024
You probably think that your square brackets are creating a 4x1 vector.
But they aren't, because of the random space characters that you included around the plus & minus operators: you need to be consistent: either all operators with spaces or none of them (simplest is none). This will fix your bug:
(V0.*cos(t).*(Lp_inv))+(xx3.*(x(1)^2).*(Lp_inv))-(xx4.*(x(2)^2).*(Lp_inv))+(x(3).*(Lp_inv))-(v_eff.*(x(4)))];
% ^ no space
Compare the effect of the space around the minus operator here:
[1 2 -3] % what you did
[1 2-3] % what you should do
[1 2 - 3] % best avoided
Also you should get rid of most of those parentheses, they make the code hard to follow (which in turn makes it harder to debug). For example this:
-(x(4))-(Jip) + (Jep.*exp(-(xx1.*(x(1)^2))))
should be simply:
-x(4)-Jip+Jep.*exp(-xx1.*x(1).^2)
Más respuestas (0)
Ver también
Categorías
Más información sobre Particle & Nuclear Physics en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!