Why is this happening in this code?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
alpedhuez
am 12 Mär. 2022
Kommentiert: alpedhuez
am 12 Mär. 2022
I run the code from https://www.mathworks.com/matlabcentral/answers/1646135-downloading-files-from-a-website-with-conditions-on-names-of-files?s_tid=srchtitle with the modification from a previous question:
baseurl = "https://www.somecompany.com/xml/";
datelimits = datetime({'20080401', '20080501'}, 'InputFormat', 'yyyyMMdd','Format','yyyyMMdd');
subfile_limit = 5; %no more than _5 -- adjust as appropriate
subfile_modifier = ["", "_" + (1:subfile_limit)] + ".xml";
for Day = datelimits(1):datelimits(2)
daystr = string(Day);
for Sub = subfile_modifier
filename = "A_" + daystr + Sub;
url = baseurl + filename;
try
outfilename = websave(filename,url);
fprintf('fetched %s\n', filename);
catch
break; %skip remaining subfiles for this date upon first failure
end
end
end
Then I got the following value for "subfile_modifier"
But the following for "Sub"
I do not understand why "_' + (1:subflie_limit) part is missing. Please advise.
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 12 Mär. 2022
The ".xml" corresponds to the "" in your submifle_modifier.
subfile_limit = 5;
subfile_modifier = ["","_" + (1:subfile_limit)] + ".xml"
If you do not want to use that extension, then remove the "".
subfile_modifier = ["_" + (1:subfile_limit)] + ".xml"
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!