How to include current array from multiple for loops into csvwrite filename
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Wan Ji
2021-8-25
Hi, try this command instead
csvwrite([num2str(lat),'_',num2str(lon),'.csv'], csvdata)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!