How to remove duplicate elements from array based on another array ?

3 ビュー (過去 30 日間)
khaled elbatawy
khaled elbatawy 2020 年 8 月 27 日
コメント済み: khaled elbatawy 2020 年 8 月 29 日
Hello everbody,
i am looking for Help .
I want to in the array leave one value and eleminate all the duplicates of the array correspond to another array
and store it in new array
as small example
% this the array that i am using as refernce to remove elemnts from b
a=[1 1 2 3 2 4 4 3];
% the array that i want to remove elemnts from
b=[1 1 0.5 1 0.5 2 2 1];
% the answer should be
b=[1 0.5 1 2];
Thanks for helping

採用された回答

madhan ravi
madhan ravi 2020 年 8 月 27 日
[~, ii]= unique(a, 'stable');
b = b(ii)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by