how to insert a single value in the matrix ?

6 次查看(过去 30 天)
hey I am creating this csv file.
I have a matrix
a = [ 2 5 8 ; 5 6 8; 8 7 8 ]
here i just want to insert one value(number of rows) at in the first row, so it will shift the whole matrix one row down !
the output file should look like
3
2 5 8
5 6 8
8 7 8
actually what above i gave you is just an example. The Mat file which i have created is a 697*5.
i am converting it in csv format using csvwrite. but before converitng it into csv i want give a value of total number of rows (i.e 697 in this case) at the top.
the csv file should look like
3
2,5,8
5,6,8
8,7,8
  2 个评论
pruth
pruth 2019-9-18
actually what above i gave you is just an example. The Mat file which i have created is a 697*5.
i am converting it in csv format using csvwrite. but before converitng it into csv i want give a value of total number of rows (i.e 697 in this case) at the top.

请先登录,再进行评论。

采纳的回答

pruth
pruth 2019-9-19
hi,
i figured out the solution for this problem.
M = length(a(:,1))
dlmwrite('test.csv',M,'delimiter',',')
N = a;
dlmwrite('test.csv',N,'delimiter',',','-append');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by