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

1 回表示 (過去 30 日間)
Ant376
Ant376 2021 年 8 月 25 日
コメント済み: Ant376 2021 年 8 月 25 日
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!

採用された回答

Wan Ji
Wan Ji 2021 年 8 月 25 日
Hi, try this command instead
csvwrite([num2str(lat),'_',num2str(lon),'.csv'], csvdata)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by