Indexing rows of a table by comparing the values between two cells
2 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!