How to reset the sequence number for the sequence number in vector?
1 回表示 (過去 30 日間)
古いコメントを表示
Reset the sequence number
I have 1 vector:
vec=[1, 2, 3, 4, 2, 1, 3, 8, 7, 9]
(lost 2 consecutive numbers 5, 6)
I want to reassign the above vector so that the sequence number is continuous.
That is, the above vector must be reset:
vec2=[1, 2, 3, 4, 2, 1, 3, 6, 5, 7]
How to do it, please help.
5 件のコメント
madhan ravi
2019 年 4 月 26 日
編集済み: madhan ravi
2019 年 4 月 26 日
@Kalyan: No, the OP wants no 8
"you can merge the statements in single line"
How?, other than commas / semicolons
採用された回答
Andrei Bobrov
2019 年 4 月 26 日
編集済み: Andrei Bobrov
2019 年 4 月 26 日
In your case:
[~,~,vec2] = unique(vec);
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!