How to reset the index in the increasing order
9 views (last 30 days)
Show older comments
Mekala balaji
on 24 Jan 2016
Commented: Walter Roberson
on 24 Jan 2016
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
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.
Accepted Answer
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];
0 Comments
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!