Index exceeds the number of array elements. Index must not exceed 0.

35 ビュー (過去 30 日間)
Eaint Honey Aung
Eaint Honey Aung 2022 年 9 月 30 日
コメント済み: Walter Roberson 2022 年 10 月 3 日
Hi Everyone,
I am trying to run a loop but it gave me this error at a certain point. How can I solve it please?
Index exceeds the number of array elements. Index must not exceed 0.
Error in tracking_Phasics_rev7_20x_BTK (line 97)
filelist = dir([froot, fstart, 'Pos', char(LocList(Loc)), '_*', fext]);
Error in f2_RunTrackingCodeScript_20x_honey (line 16)
tracking_Phasics_rev7_20x_BTK(FRoot{dd}, fstart); %Use rev2 for 40, rev1 for 120 images rev3 for colonies, rev4 for 48 images colonies, rev5 for 114
>>
  3 件のコメント
Eaint Honey Aung
Eaint Honey Aung 2022 年 9 月 30 日
What can I do to fix it?
Walter Roberson
Walter Roberson 2022 年 10 月 1 日
We would need to see more of the code

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

回答 (1 件)

Apeksha Bagrecha
Apeksha Bagrecha 2022 年 10 月 3 日
From the error message "Index exceeds the number of array element (0)", it seems that target PC settings are corrupted. Execute the below command in the command window:
>> slrtprefdir
Please navigate to the directory and delete all the contents in that specific folder. Then, please restart MATLAB. This specific procedure will clear out your SLRT preferences and you need to set up the target properties again, but this should most likely resolve the issue.
  1 件のコメント
Walter Roberson
Walter Roberson 2022 年 10 月 3 日
I don't think this is appropriate in the current situation.
In the context of the code, there are two possibilities:
  1. That LocList might be empty, so LocList(loc) would fail ; OR
  2. that LocList(loc) might be find, and the creation of the character vector [] might be fine, but that dir had previously been assigned to be an empty array instead of being a MATLAB function call at that point in the code.
Corrupted preferences are unlikely to be relevant for either of those possibilities.

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by