フィルターのクリア

How to stop overwriting?

5 ビュー (過去 30 日間)
Haron Shaker
Haron Shaker 2021 年 3 月 13 日
回答済み: Jan 2021 年 3 月 13 日
Dear all,
I wrote a function, which lists the directory of a given URL. Now I got several URLs which I want run over a loop to list all directories of the URLs in a array.
My problem is that this function overwrites the founded stuff of an URL (iteration i) with the founded directory of the followed URL of (iteration = i+1) and so on, until it just gives the directory of the last URL of the loop instead of all. How can I change it?
The URLs are attached.
folderCellArray = {}
data = readcell('founded_medicine_folder.xls')
saveFileName = 'try.xls'
for i = 1:4
url = data{i,1}
dd= listAllDirectories(url, folderCellArray, saveFileName)
%I guess some concat step is missing here
end

採用された回答

Jan
Jan 2021 年 3 月 13 日
Maybe:
dd = cell(1, 4);
for i = 1:4
url = data{i, 1};
dd{i} = listAllDirectories(url, folderCellArray, saveFileName)
end
But what happens inside listAllDirectories? The name "saveFileName" might mean, that something is overwritten there. Then either instruct this function to append the data. Or use a new file name in each itereation:
for i = 1:4
url = data{i, 1};
saveFileName = sprintf('try%03d.xls', i);
dd = listAllDirectories(url, folderCellArray, saveFileName)
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by