Indexing rows of a table by comparing the values between two cells
조회 수: 1 (최근 30일)
이전 댓글 표시
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167189/image.jpeg)
Hi everyone, I have a table like the above attachment. Column A and Column B contains some elements in terms of cell array. I want to create the third column (Level) as the resultant column; based on the following logic.
- The row for which, value of cell A = value of cell B will be labeled 1. (In the 3rd row, the value of column A=value of column B= 3, hence labeled 1)
- Next, the preceding value will be removed from all the cells of column A; and the step 1 will be repeated until all the rows are labeled. (In the second step, 3 will be removed from all the cells, hence both row 1 and row 2 will be labeled as 2;In the final step, elements {1,2} will be further removed from the last row resulting the level as 3 )
I am using cell2mat and setdiff functions to compare the values across the cells, but i am not able to frame the above 2 logical steps to run my code successfully. I have just started learning MATLAB, Any help will be highly appreciated.
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!