필터 지우기
필터 지우기

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 CenterFile Exchange에서 Workspace 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