How to transform data from rows to columns, based on a specific column
Show older comments
Currently i have a cell array containing a batch ID in de 1st column, and a position in the 2nd column. An example is shown below.
Batch Pos
001 1
001 3
001 8
002 1
003 5
003 8
007 2
007 4
007 7
007 8
011 6
013 2
014 1
014 3
014 5
014 6
What I am trying to achieve is to have only 1 row per batch ID, and convert the pos to seperate column with either True or 1. The pos will always be a number between 1 and 8.
Batch Pos 1 Pos 2 Pos 3 Pos 4 Pos 5 Pos 6 Pos 7 Pos 8
001 TRUE TRUE TRUE
002 TRUE
003 TRUE TRUE
007 TRUE TRUE TRUE TRUE
011 TRUE
013 TRUE
014 TRUE TRUE TRUE TRUE
Can anyone help me in the right direction how to achieve this, since i am really struggling with this.
Accepted Answer
More Answers (0)
Categories
Find more on Christmas / Winter in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!