Sampling a large matrix using column indices
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to sample a large(17x16602) matrix for use as a kernel for a kernel kmeans algorithm. Because the matrix is very large(and full), I decided sample it randomly. I now have a list of 1000 column indices which I want to use to extract data from my matrix. I have tried all of the simple indexing techniques, but all I am getting are the values within the first row that I want. What I have so far is:
L=length(x);
IDX_RAND=randperm(L);
IDX_SAMP=IDX_RAND(1:1000);
What I want is to use the column values in IDX_SAMP to extract a 17x1000 matrix for use in my kernel. The desired result would return the column value in IDX_SAMP and preserve the trailing 16 rows in that column. Any help or clarification requests are appreciated. Thanks!
0 comentarios
Respuesta aceptada
Walter Roberson
el 26 de Dic. de 2012
If you are looking for the value of the same columns for each of the rows, then
x(:, IDX_SAMP)
Note: I advise you to use L = size(x,2) instead of L = length(x) as length() does not always choose the same dimension.
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!