MATLAB Answers

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

1 view (last 30 days)
pradeep kumar
pradeep kumar on 14 Sep 2017
Edited: pradeep kumar on 14 Sep 2017
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.

Answers (0)

Community Treasure Hunt

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

Start Hunting!