How to create filename with variable within loop
Afficher commentaires plus anciens
Good morning guys!
My task is to create filenames that correspond to some weather stations I have in my hands. I am attaching a .txt with stations' names. Want I want to have in the end are filenames like that:
Hourly Data Airport 2015.txt
Hourly Data Eptapurgio 2015 txt.
and so on. Obviously I am doing it wrong... Could you please take a look at my code (several lines are missing because it's long enough) ang guide me to a solution? Thanks in advance!
for i=1:size(stations,1)
name = stations( i, 1 );
network = stations (i, 'Network');
network.(1);
name.(1);
networkstr = char(network.(1));
namestr = char(name.(1));
indx = strfind (list1, namestr) ;
for j = 1:size(indx, 1)
if (indx{j,1}>0)
if (strfind (list1{j,1}, '2015') > 0)
if (strfind(list1{j,1}, 'xlsx') > 0)
for m=1:size(vars,1)
if(~exist([output_path,'\',namestr,'\',strrep(vars{m},' ','_'),'\'],'dir'))
mkdir([output_path,'\',namestr,'\',strrep(vars{m},' ','_')])
end
end
fname = (output_path,'\',namestr,'\', 'Hourly Data ' ,strrep(stations(i,1), '2015.txt');
writetable(Hourly_Data,fname);
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Weather and Atmospheric Science dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!