필터 지우기
필터 지우기

Retaining the length of matrix after difference

조회 수: 1 (최근 30일)
Anu Sharma
Anu Sharma 2022년 3월 22일
답변: Voss 2022년 3월 22일
A matrix
A1 = [2 4 5 6 7 8 9 10 11 3 ];
A2 = [ 2 7 10];
A1 and A2 has some coomon values. I want to find the matrix A3 with no similar value of A1 and A2 and the length A1 must be retained.
A3 = [0 4 5 6 0 8 9 0 11 3];
Length will be equal to A1. but values same as in A2 will have 0 in there place

답변 (1개)

Voss
Voss 2022년 3월 22일
A1 = [2 4 5 6 7 8 9 10 11 3 ];
A2 = [ 2 7 10];
A3 = A1;
A3(ismember(A1,A2)) = 0
A3 = 1×10
0 4 5 6 0 8 9 0 11 3

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by