how to insert a single value in the matrix ?

5 Ansichten (letzte 30 Tage)
pruth
pruth am 18 Sep. 2019
Beantwortet: pruth am 19 Sep. 2019
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 Kommentare
KALYAN ACHARJYA
KALYAN ACHARJYA am 18 Sep. 2019
What would be size of output matrix?
pruth
pruth am 18 Sep. 2019
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

pruth
pruth am 19 Sep. 2019
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');

Weitere Antworten (0)

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by