Sampling a large matrix using column indices

2 次查看(过去 30 天)
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!

采纳的回答

Walter Roberson
Walter Roberson 2012-12-26
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.
  1 个评论
Jacob Moses
Jacob Moses 2012-12-26
Thank you, this is exactly what I needed. And I'll keep in mind using size for this project.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by