【问题标题】:How to loop through a set of ranges from an array inside a for loop using readtable?如何使用 readtable 遍历 for 循环内的数组中的一组范围?
【发布时间】:2020-12-01 19:23:13
【问题描述】:

我有一个 for 循环,它使用电子表格中的参数计算值。我希望 for 循环遍历不同的范围,但我收到一个错误,我不知道如何修复它。

e_params_components = ["'G3:G5'","'D3:D5'","'F3:F5'","'E3:E5'"];
h_params_components = ["'G6:G8'","'D6:D8'","'F6:F8'","'E6:E8'"];
for i = 1 : length(Material_Names)
    params_e = table2array(readtable(databaseFilename,  'Range', e_params_components(1)));    % Read in width indep parameters for e- - hardcoded for GaAs
    params_h = table2array(readtable(databaseFilename,  'Range', h_params_components(1)));    % Read in width indep parameters for holes - hardcoded for GaAs
    alpha_ = ionCoeff(params_e(1), params_e(2), params_e(3), Efield);
    beta_ = ionCoeff(params_h(1), params_h(2), params_h(3), Efield);
    k_ = beta_./alpha_;                        % Ionization coefficient ratio
    k_values = k_values + k_(i);
end

我收到以下错误:

Error using readtable (line 198)
Unable to determine range. Range must be of the form 'A1' (cell), 'A:B' (column-select), '1:5' (row-select), 'A1:B5'
(rectangle-select), or a valid named range in the sheet.

我应该能够使用包含在 e_params_copmponents 中的字符串放入读取表函数中

【问题讨论】:

    标签: arrays excel matlab matlab-deployment


    【解决方案1】:

    你有很多引号。

    例如:

    "'G6:G8'" 是字符串 'G6:G8' 你希望它是字符串 G6:G8

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-18
      • 1970-01-01
      • 1970-01-01
      • 2021-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多