Effacer les filtres
Effacer les filtres

How to include current array from multiple for loops into csvwrite filename

3 vues (au cours des 30 derniers jours)
Ant376
Ant376 le 25 Août 2021
Commenté : Ant376 le 25 Août 2021
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!

Réponse acceptée

Wan Ji
Wan Ji le 25 Août 2021
Hi, try this command instead
csvwrite([num2str(lat),'_',num2str(lon),'.csv'], csvdata)

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by