How to sort a table based off of values in one row in MATLAB
35 views (last 30 days)
Show older comments
I am working on analyzing a data set for a 2AFC task. I have a table called 'SmallerTable,' that has multiple columns. One of my columns titled 'GroupB', I have various numbers ranging from 1:28 in this column. I would like to put these in order so that row one has the number 1, row two has the number 2 and so on. I would like every respective colum to sort their rows according to how this GroupB column is sorted.
Would anyone be able to help me with this?
0 Comments
Answers (2)
the cyclist
on 8 Mar 2021
Edited: the cyclist
on 8 Mar 2021
Take a look at the documentation for the sortrows function, in particular the example on sorting rows of tables by variables. The syntax is basically
tblB = sortrows(tblA,vars)
where vars is a cell array with the variable name(s).
2 Comments
the cyclist
on 8 Mar 2021
Can you upload your data in a MAT file, using the paperclip icon in the toolbar?
If you cannot for some reason, could you upload a sample (perhaps just a few rows and columns) of the data that gives the same error?
See Also
Categories
Find more on Shifting and Sorting Matrices 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!