MATLAB Answers

0

sub2ind.m -- trying to use with a 2D matrix

Asked by Matlab2010 on 26 Nov 2013
Latest activity Answered by Sean de Wolski
on 26 Nov 2013
I have a matrix
data = rand(100,100);
I also have a index into that matrix
IDY = randperm(100);
I wish to reorder the data matrix by the order in IDY.
I thought sub2ind could help me, but I have not been able to get it working.
FYI: the matrix is a correlation matrix. Each element refers to a variable. I wish to "re-order" the correlation matrix according to the ordering in IDY.
thank you

  0 Comments

Sign in to comment.

Tags

2 Answers

Answer by Azzi Abdelmalek
on 26 Nov 2013
Edited by Azzi Abdelmalek
on 26 Nov 2013

data(IDY)
Or maybe
data(IDY,:)

  0 Comments

Sign in to comment.


Answer by Sean de Wolski
on 26 Nov 2013

data(IDY,:)
To reorder all rows or for columns
data(:,IDY)

  0 Comments

Sign in to comment.