Indexing rows of a table by comparing the values between two cells
1 次查看(过去 30 天)
显示 更早的评论
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!