【问题标题】:Scilab Invalid IndexScilab 无效索引
【发布时间】:2020-05-19 20:58:18
【问题描述】:

我已经开始学习 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

【问题讨论】:

    标签: scilab


    【解决方案1】:

    在 Scilab 中,矩阵的索引从 1 开始,而不是从 0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-01
      • 1970-01-01
      • 2017-10-11
      • 2021-10-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多