count rows from column file and store in a new column

someone could help me to see how to make a column that increases in numbers according to the number of entries from a column file?
I have this matrix: A = [1,2,3,4,5 ; 5,5,5,5,5; 5,5,5,5,5; 5,5,5,5,5; 5,5,5,5,5 ] and i want to add new column with number of each file.
and add this column to an existing file .

Answers (1)

If both matrices have the same number of rows, then you can combine them using concatenation brackets ([]). For example
A = [1,2,3,4,5 ; 5,5,5,5,5; 5,5,5,5,5; 5,5,5,5,5; 5,5,5,5,5 ];
B = rand(5, 10); % random matrix
C = [A B] % join A and B

Categories

Tags

Asked:

on 31 Oct 2020

Edited:

on 31 Oct 2020

Community Treasure Hunt

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

Start Hunting!