how can I write two matrix into the same csv file
古いコメントを表示
I'm trying to write two matrix into csv file using writematrix I tried to speart them with line as divider in the file but I couldn't do that I just want them to be in the same file but add headline or something to indicate which one is matrix a and b
so the file will be something like this (or next to each other)
a
1 4 9
16 25 36
49 64 100
b
1 4 9
16 25 36
49 64 100
how can I do that with writematrix?
a = [ 11 12 13;
14 15 16;
17 18 20]
b= [ 1 4 9;
16 25 36;
49 64 100]
writematrix(a,'a.csv','Delimiter','tab');
writematrix(b,'a.csv','Delimiter','tab');
採用された回答
その他の回答 (1 件)
Mohammad Farhad Aryan
2020 年 4 月 10 日
If you are using Matlab 2019, you could use the following recommended function to write a matrix to a set of files.
writematrix(a,'a.csv');
writematrix(b,'a.csv','WriteMode','append');
But there is no option to add a separator line or headline in between.
If you want to read the .csv file, use the following function.
a_file = readmatrix('a.csv');
Hope this can help.
カテゴリ
ヘルプ センター および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!