How to include current array from multiple for loops into csvwrite filename
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have the following for loop within a for loop:
for lat = [1.5,2,3.5]
for lon = [1,2.5,3]
for year[1990:2019]
(stuff happens)
end
csvdata=[var1,var2,var3]
csvwrite(lat lon.csv, csvdata)
end
end
each output of the lon loop needs to be stored in a seperate file, I would like the CSV file name to be the lat and lon of the current loop so that the csv does not keep overwriting. I do not want to append.
I do not know if it is worth noting that the lat and lon numbers contain decimals.
I have struggled with various things but cannot seem to get it to work. I am new to matlab so appreciate this may be a messy way of doing what I want to do.
Thanks in advance for any help!
0 Kommentare
Akzeptierte Antwort
Wan Ji
am 25 Aug. 2021
Hi, try this command instead
csvwrite([num2str(lat),'_',num2str(lon),'.csv'], csvdata)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Text Files 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!