필터 지우기
필터 지우기

Compare elements within cell array

조회 수: 3 (최근 30일)
Tha saliem
Tha saliem 2017년 12월 28일
댓글: Tha saliem 2018년 1월 2일
Hi all
I have a cell array A
A={[1x4 cell];[1x3 cell];[1x5 cell]}
A{1,1}= {[1,-0.03,0.1,1.3,0,0.23,1,0,0.2],[1,0.6,0.1,2,0,0.6,0.6,0,0.6],[1,-0.15,0,1.4,0,0.35,1,0,0.3],[2,-0.2,0.1,3,0,0.4,0,0,0.4]}; similarly values for other A{2,1} and A{3,1}
I want to compare all elements of A with every other element. Like A{1,1}{1,1} with A{1,1}{1,2}, A{1,1}{1,3} and A{1,1}{1,4} and similarly A{1,1}{1,2} with all others to find which one is less. If every single element (col values) is less it means that row is less than other row. store index of that row in a separate array. and same for other elements of A.
Kindly help.

채택된 답변

KSSV
KSSV 2017년 12월 28일
YOu can get the minimum value of each cell using cellfun and min.
A{1,1}= {[1,-0.03,0.1,1.3,0,0.23,1,0,0.2],[1,0.6,0.1,2,0,0.6,0.6,0,0.6],[1,-0.15,0,1.4,0,0.35,1,0,0.3],[2,-0.2,0.1,3,0,0.4,0,0,0.4]};
cellfun(@min,A{1})
  댓글 수: 4
Tha saliem
Tha saliem 2017년 12월 28일
편집: Tha saliem 2017년 12월 28일
Thank you so much. I got the idea of doing it. One more thing i want to ask is that using this code I can compare row1 with row2 row3 and row4. I want to compare remaining rows with each other as well. Like row2 with row1 row3 and row 4. Row3 with row1 row2 and row4 and similarly other rows.
Is there any simple way to do it without writing this statement for every single row or using loops. because i have a large dataset on which this comparison will be done.
Tha saliem
Tha saliem 2018년 1월 2일
Can you please help on this question because you have solved the problem related to it here:
https://www.mathworks.com/matlabcentral/answers/375162-get-row-no-where-comparison-gives-1

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by