我已经开始学习Scilab了。我想问一下,为什么当我在我的脚本中使用矩阵时,编译器上显示“无效索引”。在本例中,我希望将python代码重写为scilab代码。
这是我想要的scilab代码和图片。谢谢

// Semiconductor Parameter Definition
k = 8.617333262145e-5; // Boltzmann Constant (eV/K)
q = 1.602e-19; // Elementary charges
h = 6.62606957e-34; // Planck constant (eV/K)
m0 = 9.10938291e-31; // Mass of electron (kg)
mn = 1.08*m0; // Si electron effective mass (kg)
mp = 0.56*m0; // Si hole effective mass (kg)
Temp = 1000 + 273; // Temperature (Kelvin)
Alpha = 4.73E-4; // Fitting alpha param (eV/K)
Beta = 636; // Fitting beta param (K)
Eg_o = 1.166; // Si - Band gap reference room temp (eV)
Eg = Eg_o - ((Alpha*Temp^2)/(Temp+Beta)); // Si - Band gap for temp dependence (eV)
// Difussion Parameter for Boron Doped
Dixo = 0.037e-4; // m2/sec
Dixe = 3.46; // eV
Dipo = 0.72e-4; // m2/sec
Dipe = 3.46; // eV
Dix = Dixo*exp(-Dixe/(k*Temp));
Dip = Dipo*exp(-Dipe/(k*Temp));
// Intrinsic Semiconductor for Temperature Dependence
Nc = 2*(2*%pi*mn*k*Temp/h^2)^1.5; // Density of States in the Conduction Band
Nv = 2*(2*%pi*mp*k*Temp/h^2)^1.5; // Density of States in the Valance Band
ni = sqrt(Nc*Nv*exp(-Eg/(k*Temp))); // Intrinsic Carrier Concentration
// Initialization Parameter
iter_max = 10; // Iteration Maximal
crit = 1e-12;
mesh_time = 500; // Number of Mesh for time
mesh_length = 100; // Mesh length for x
time_max = 500; // total time (second)
length_max = 2e-6; // length x (meter)
dtime = time_max/mesh_time; // step-size for time (second)
dlength = length_max/mesh_length; // step-size for x (meter)
// Doping Concentration for Semiconductor
N_d = 1e18; // Carrier concentration for substrate (cm-3)
N_a = 1e15; // Carrier concentration for borond doped (cm-3)
// Variables for Making Matrix
x = zeros(mesh_length); // Interval of mesh length
times = zeros(mesh_time); // Interval of mesh times
Nd = zeros(mesh_length); // Substrate Donor
Na = zeros(mesh_length); // Acceptor Dopant
N_carr = zeros([mesh_length, mesh_time]); // Quasi-equilibrium for carrier
Diff = zeros([mesh_length, mesh_time]); // Non-dimeNdion parameter for Diffusion
C = zeros([mesh_length, mesh_time]); // Carrier concentration
/////////////////////////////////////////////////////////////// Forward Difference Method \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Initial Concentration at t = 0
for i = 1:mesh_length
x(i) = -length_max/2 + i*dlength // Interval for length semiconductor
if i > 1:(mesh_length/2) then // Right-side of the half x-grid
Nd(i) = 0 // Donor Substrate (cm-3 to m-3)
Na(i) = N_a*1e6 // Acceptor dopant (cm-3 to m-3)
C(i,0) = abs(Nd(i) - Na(i)) // Initial Concentration
else // Left-side of the half x-grid
Nd(i) = N_d*1e6; // Donor Subtrate (cm-3 to m-3)
Na(i) = N_a*1e6; // Acceptor dopant (cm-3 to m-3)
C(i,0) = abs(Nd(0) - Na(0));
end,
end发布于 2020-05-19 20:58:18
在Scilab中,矩阵索引从1开始,而不是从0开始
https://stackoverflow.com/questions/61872410
复制相似问题