File Exchange

image thumbnail

mg_getRowsWithKey.c​pp

version 1.0.0.0 (5.72 KB) by Matthew Gunn
For each unique id, it finds the rows with that id. Mex function.

1 Download

Updated 10 Nov 2015

View License

If you have a large data matrix DATA and a vector of ids ID_VECTOR, you can do the following:
[unique_ids, map] = mg_getRowsWithKey(ID_VECTOR);
for(i =1:length(unique_ids)),
group_i_data = DATA(map{i},:);
//insert what you want to do on group_i_data here
end
ID_VECTOR can either be an n by 1 vector of real doubles or an n by 1 cell array of strings

compile with mex mg_getRowsWithKey.cpp

Cite As

Matthew Gunn (2021). mg_getRowsWithKey.cpp (https://www.mathworks.com/matlabcentral/fileexchange/53913-mg_getrowswithkey-cpp), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

Matthew Gunn

Better to compile with mex -largeArrayDims mg_getRowsWithKey.cpp

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!