How to reset the index in the increasing order

9 views (last 30 days)
Hi,
I have the below table by time (old to latest), the first column is the index, but it resets some time. So, I want to add new column "NewIndex", and assign the index from 1 ~. Can anyone kindly help which command I should use here.
Table1:
2234 A 2015/3/4
2456 B 2015/3/5
4567 G 2015/3/6
4673 F 2015/3/7
2 A 2015/3/8
5 F 2015/3/9
and my output I want as below:
1 2234 A 2015/3/4
2 2456 B 2015/3/5
3 4567 G 2015/3/6
4 4673 F 2015/3/7
5 2 A 2015/3/8
6 5 F 2015/3/9
Amy thanks in advance.
  3 Comments
Mekala balaji
Mekala balaji on 24 Jan 2016
I want output table I have mentioned, from input (Table1), data is cell array. I just want to add one column to the Table1 (i.e, index 1~..).
Walter Roberson
Walter Roberson on 24 Jan 2016
There happens to be a MATLAB type called "table", so we needed to know if you meant that or if you meant "table" in a different sense. Your reference to cell array tells us that you did not mean the "table" data type.

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 24 Jan 2016
Here is one way, assuming "C" is your original cell array.
nr = size(C,1);
CC = [num2cell((1:nr)'), C];

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!