Throw an error when more than one result is returned

1 回表示 (過去 30 日間)
ArtLabbe12
ArtLabbe12 2020 年 6 月 1 日
コメント済み: ArtLabbe12 2020 年 6 月 1 日
I have this running at the beginning of my script where it will look for two files in the directory the script is run in. I'm trying to add a check to throw an error if the 'ls' command returns more than one result. For example if there is 01-data.csv and 02-data.csv in the same directory, it will report an error that more than one result was found.
[status, data1] = system('ls *data.csv');
[status, info1] = system('ls *info.csv');
data1 = readtable(deblank(data1));
info1 = readtable(deblank(info1));
I am not too familiar with MATLAB so any help would be greatly appreciated. Thank you!

採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 6 月 1 日
use
files=dir('*data.csv');
size(files)
  1 件のコメント
ArtLabbe12
ArtLabbe12 2020 年 6 月 1 日
Thank you, this has given me some ideas of how to continue.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by