Writting arrays into a csv file

2 ビュー (過去 30 日間)
Chen Zhu
Chen Zhu 2017 年 3 月 28 日
回答済み: KSSV 2017 年 3 月 28 日
I have a for loop, I want to write the array generated in the for loop into a csv file.
for k = 1 : numberOfImagesToProcess
array1=.... (This is a one dimenial array)
end
For example, if the array1 generated in the first iteration is 1 2 3 and array1 generated in the second iteration is 4 5 6, I want to get csv file in the following format:
1 2 3
4 5 6
However, I tried to use csvwrite('csvlist.dat',array1) inside the for loop I get:
4
5
6
The result of first iteration is overwrote by the second iteration...
Thanks!

採用された回答

KSSV
KSSV 2017 年 3 月 28 日
a = [1 2 3; 4 5 6] ;
dlmwrite('test.csv',a(1,:),'delimiter',',');
dlmwrite('test.csv',a(2,:),'delimiter',',','-append');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by