Sampling a large matrix using column indices

2 ビュー (過去 30 日間)
Jacob Moses
Jacob Moses 2012 年 12 月 26 日
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 Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by