Indexing rows of a table by comparing the values between two cells

조회 수: 1 (최근 30일)
pradeep kumar
pradeep kumar 2017년 9월 14일
편집: pradeep kumar 2017년 9월 14일
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.
  1. 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)
  2. 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개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by