Deleting non identical values of 2 vectors?

조회 수: 8 (최근 30일)
Mirko Tomic
Mirko Tomic 2022년 7월 4일
편집: MJFcoNaN 2022년 7월 4일
Hi, i have 2 vectors:
a = [5 6 1 8 4 7 3]
b = [4 5 6 2]
the outcome i need is --> a = [5 6 NaN Nan 4 NaN NaN]

채택된 답변

MJFcoNaN
MJFcoNaN 2022년 7월 4일
편집: MJFcoNaN 2022년 7월 4일
Hello,
The function of ismember may help you
a = [5 6 1 8 4 7 3];
b = [4 5 6 2];
[lia,locb]=ismember(a,b);
a(~lia)=NaN
a = 1×7
5 6 NaN NaN 4 NaN NaN

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by