I'm new to MATLAB and am stumped with an assignment for my research position. I need to create a For loop that compares two sets of data (day one and day 2) from 180 electrodes. However, we only have overlapping data from 175 electrodes (common_chans). I need to make a list of all possible electrode combinations from day 1 and day 2 of the common_chans electrodes, and have it display as an Y x 2 matrix for the all the combinations. Any suggestions on how to do this? I feel like it's simple but I just don't have the background. Thanks!
Asked
Active
Viewed 53 times
0
-
1[This](http://stackoverflow.com/questions/21895335/generate-a-matrix-containing-all-combinations-of-elements-taken-from-n-vectors) may help – Luis Mendo Jul 29 '14 at 22:11
-
Glad it helped :-) I wasn't completely sure what you were asking, but it seemed to be similar to that – Luis Mendo Jul 29 '14 at 22:48
-
Another nifty File-exchange tool one can use in such cases - [`allcomb`](http://www.mathworks.in/matlabcentral/fileexchange/10064-allcomb) – Divakar Jul 30 '14 at 04:47
1 Answers
0
Not sure I understood your question correctly, but if you need to make a list of all possible pairs:
nchoosek(1:175,2)
This displays a 15225 x 2 matrix.
This assumes that you don't care about the order (e.g. once you compared electrode 3 with electrode 6, this assumes you don't want to compare again electrode 6 with electrode 3). So this is different from Luis' link.

nicolas
- 3,120
- 2
- 15
- 17
-
Thanks for the function. Yea, the issue is the electrodes aren't named by number, but rather by neurological location (so RT1 for right temporal location 1). So I think I just need to apply it to the string and hopefully it will spew out the pairs. The catch is there can't be repeats (so no "RT1, RT2" if "RT2, RT1" already exists), so yes, that is perfect. – Britt Davis Jul 29 '14 at 23:59