how can I write two matrix into the same csv file
Afficher commentaires plus anciens
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');
Réponse acceptée
Plus de réponses (1)
Mohammad Farhad Aryan
le 10 Avr 2020
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.
Catégories
En savoir plus sur Text Files dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!