Subtracting 2 matrices of different dimensions
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
a{1}=[1 3 4 5;
      3 3 4 5;
      5 5 4 5
      2 4 2 6;
      6 5 2 6
      7 2 3 1;]
[b,idx]=unique(a{1}(:,3:4),'rows','stable');
uniquematrix{1}=a{1}(idx,:)
1  3  4  5  %Content of uniquematrix{1}
2  4  2  6
7  2  3  1
After a{1}-uniquematrix{1}
3 3 4 5 %My desired output
5 5 4 5
6 5 2 6
Is there a function to directly perform a{1}-uniquematrix{1}?
댓글 수: 0
채택된 답변
  Azzi Abdelmalek
      
      
 2013년 8월 29일
        a=[1 3 4 5;
  3 3 4 5;
  5 5 4 5
  2 4 2 6
  6 5 2 6
  7 2 3 1]
[b,idx]=unique(a(:,3:4),'rows','stable')
out=a(setdiff(1:size(a,1),idx),:)
댓글 수: 0
추가 답변 (1개)
  Azzi Abdelmalek
      
      
 2013년 8월 29일
        a=[1 3 4 5;
   3 3 4 5;
   5 5 4 5
   2 4 2 6
   6 5 2 6
   7 2 3 1]
[b,idx]=unique(a(:,3:4),'rows','stable')
uniquematrix=a(idx,:)
n1=size(a,1)
n2=size(uniquematrix,1)
uniquematrix=[uniquematrix;zeros(n1-n2,size(a,2))]
out=a-uniquematrix
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

