matlab如何实现两个矩阵的去同存异

조회 수: 1 (최근 30일)
yongjie
yongjie 2024년 6월 12일
댓글: yongjie 2024년 6월 14일
A = [1 3 7; 6 4 2];
B = [1 3];两个矩阵怎么去同存异得到矩阵[6 4 2]

답변 (1개)

halleyhit
halleyhit 2024년 6월 13일
편집: halleyhit 2024년 6월 13일
我猜你是要
setdiff(A,B)
但为啥A和B计算结果是642,7呢
  댓글 수: 1
yongjie
yongjie 2024년 6월 14일
C=setdiff(A(:,1:2),B,'rows')
D=A(ismember(A(:,1:2),C,'rows'),:)
应该这样

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

카테고리

Help CenterFile Exchange에서 MATLAB 快速入门에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!