These column vectors will tell us which rows match a particular name located in your table. As such, we will have five column vectors where each column vector is placed into an individual cell. To find the locations of each valid name in our table, I use find and the locations are placed into a column vector. I use arrayfun and go through each name in names, find those rows that share the same name as one we are looking for, and place those row locations into individual cells these are stored into ind. The next line goes through all of the unique names and finds those locations / rows in the table that share that particular name. The first line finds all unique names through unique and we store them into names. Let's go through each line of code slowly. ![]() As such, do something like this: names = unique(T.name) %// 1 Once you're done, reshape the matrix to 5 x 2 as you have said. First figure out where each name has values located in the table, then cycle through each name and place the first two values encountered for each name into individual cell arrays.
0 Comments
Leave a Reply. |