How do I see which cell that the components of a vector land in, in a cell array??
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
Say I have a cell array, A, and a vector, B. I want to figure out which cell each component of the vector lands in. For example.
A = { [1 5 6] [15 3 10 7] [13 14 2 8] }
B = [1 10 5 2]
Output = [1 2 1 3]
Also, not all cells in A are equal in size, some are however. The numbers contained in B will always be found somewhere in A, but not the other way around.
댓글 수: 0
채택된 답변
  madhan ravi
      
      
 2020년 4월 7일
        c = arrayfun(@(y)arrayfun(@(x)(any(B(x)==A{y}).*y),1:numel(B),'un',0),1:numel(A),'un',0);
Output = sum(cell2mat(cat(1,c{:})))
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

