Excluding Constants from Consecutive numbers

조회 수: 1 (최근 30일)
DARLINGTON ETAJE
DARLINGTON ETAJE 2019년 7월 23일
댓글: DARLINGTON ETAJE 2019년 7월 23일
Here is the scenario.
A=[1;3;4;5;2;4;5;2;1;2;4;2;4;2;1;3;4;2;1;9];
B=[1;2;3;4;4;4;4;5;6;7;8;9;9;9;10;11;12;13;14;14];
C=[0;3;5;6;7;8;9;10;5;4;6;77;6;5;65;34;1;8;9;21];
D=[A B C]
My first aim is to convert B to become
B=[1;2;3;4;5;6;7;8;9;10;11;12;13;14;]; %excluding all the constant scenarios
My second aim would be to ensure D only contains the new B (all deleted rows of B should also be deleted in A and C.
Thanks

채택된 답변

Guillaume
Guillaume 2019년 7월 23일
[~, rows] = unique(D(:, 2), 'stable');
newD = D(rows, :)
  댓글 수: 1
DARLINGTON ETAJE
DARLINGTON ETAJE 2019년 7월 23일
Thank You...this answer is simplified and straight to the point. Cheers

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by