フィルターのクリア

Index exceeds matrix dimensions Error

1 回表示 (過去 30 日間)
Ji Li
Ji Li 2018 年 9 月 18 日
コメント済み: Walter Roberson 2018 年 9 月 19 日
I have a function which writes inputs from Excel. The function doesn't report any errors in Matlab, but when I converted it into an Excel add-in, it tells me "Index exceeds matrix dimensions". The error occurs at the "Horizon" line in the code. How can I find out what the problem really is?
Inputs InputsData = xlsread(inputFileName, 'Portfolio', 'U4:U15');
N = InputsData(1);
K = InputsData(2);
PERC = InputsData(3);
PERC_T = InputsData(4);
GLOB = InputsData(5);
COUT = InputsData(6);
SEC = InputsData(7);
FI = InputsData(8);
LIMIT = InputsData(9);
HORIZON = InputsData(10);
ALC = InputsData(11);
CUT = InputsData(12);
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 9 月 18 日
The first line is not MATLAB code?
Ji Li
Ji Li 2018 年 9 月 19 日
No, it is code. Sorry I should’ve deleted the first word “Inputs”. Also, “inputFileName” is predefined, it refers to my Excel file name.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2018 年 9 月 19 日
For whatever reason, U13, U14, and U15 are not present in the returned data. That could occur with that code if the values in those locations are all not numeric, as well as for the case where those values all just do not exist.
  2 件のコメント
Ji Li
Ji Li 2018 年 9 月 19 日
Oh, You’re right! They are Boolean values in the three cells (TRUE/FALSE). But how could them be read into Matlab?
Walter Roberson
Walter Roberson 2018 年 9 月 19 日
[~, ~, InputsRaw] = xlsread(inputFileName, 'Portfolio', 'U4:U15');
N = InputsData{1};
K = InputsData{2};
PERC = InputsData{3};
PERC_T = InputsData{4};
GLOB = InputsData{5};
COUT = InputsData{6};
SEC = InputsData{7};
FI = InputsData{8};
LIMIT = InputsData{9};
HORIZON = InputsData{10};
ALC = InputsData{11};
CUT = InputsData{12};
I do not know what datatype HORIZON, ALC, and CUT will come out as.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePortfolio Optimization and Asset Allocation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by