How to check if a specific 'part' of a cell array exists?

10 ビュー (過去 30 日間)
Thomas Hyatt
Thomas Hyatt 2019 年 7 月 14 日
コメント済み: Thomas Hyatt 2019 年 7 月 14 日
I am trying to write a script that will check if (as x increments)
burstcountdata{x}
exists, so that if it doesn't it can be created with
burstcountdata{x} = []
so it can then be referenced. The program has to be run repeatedly (because of how the data exists across multiple .mat files of the same name) so it cannot constantly be overwriting testarray{x} as [], it has to only write it if it doesnt exist.
Currently I have:
if exist(burstcountdata{x}, 'var') == 0
burstcountdata{x} = [];
end
but this makes matlab throw a fit because it's burstcountdata{x} instead of 'burstcountdata{x}', and I don't know how to make x be treated as a variable within 'burstcountdata{x}'

採用された回答

Walter Roberson
Walter Roberson 2019 年 7 月 14 日
numel(burstcountdata) < x
Then the element doesn't exist
  1 件のコメント
Thomas Hyatt
Thomas Hyatt 2019 年 7 月 14 日
Ahhhhhhh yes. Thank you. Didn't think of that!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by