필터 지우기
필터 지우기

sampling from a matrix

조회 수: 17 (최근 30일)
Mohamad
Mohamad 2013년 12월 20일
댓글: Mohamad 2013년 12월 21일
Hello I am going to sample some columns in a matrix and return the columns that are not selected during the sampling. could you please help me?

채택된 답변

José-Luis
José-Luis 2013년 12월 20일
bla = rand(10);
%Columns you sample:
my_cols = [1 5 7];
%Extract them:
sample = bla(:,my_cols);
nCols = 1:size(bla,2);
no_sample = nCols(~ismember(nCols,my_cols));
no_sample =bla(:,no_sample);
  댓글 수: 1
Mohamad
Mohamad 2013년 12월 21일
Dear Jose Thank you very much.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

dpb
dpb 2013년 12월 20일
편집: dpb 2013년 12월 20일
Sample how? If use randperm, say, as
icol=randperm(size(x,2),N);
to select N random columns from the array x to get the "nonsampled" columns you could instead simply use
inot=randperm(size(x,2),size(x,2)-N);
which is simply picking a random set of the obverse size to not sample--same thing in the end.
Or, if you are using the sampled column values first and then wanting the ones that weren't used both then first select as in the former and the other columns are simply
inot=setdiff([1:size(x,2)],icol);
  댓글 수: 1
Mohamad
Mohamad 2013년 12월 21일
hi dear dpd Thank you very much for the informative comments.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by