필터 지우기
필터 지우기

Remove random columns from a big matrix?

조회 수: 2 (최근 30일)
stelios loizidis
stelios loizidis 2019년 8월 6일
댓글: Adam Danz 2019년 8월 6일
Hello,
I have this issue: I want to randomly remove 3000 columns from a big matrix with size 1600X8500. below I have a code I wrote but when I run it the matlab outputs the following error: Index exceeds the number of array elements (1650)
A=[x1 x2 ...] % 1600by8500 matrix
k=randperm(size(A,1));
B=A;
B(:,k(1:3000))=[];
Your help is important!!

채택된 답변

Adam Danz
Adam Danz 2019년 8월 6일
If A is 1600 x 8500 as you describe, then the line below will only create 1600 elements so you can't use an index of 1:3000.
k=randperm(size(A,1));
Instead, you want to use the 2nd dimension of A
k=randperm(size(A,2));
% ^
  댓글 수: 2
stelios loizidis
stelios loizidis 2019년 8월 6일
I tried it and it works fine. Thank you very much!!!!!
Adam Danz
Adam Danz 2019년 8월 6일
Glad I could help!

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

추가 답변 (1개)

madhan ravi
madhan ravi 2019년 8월 6일
B(:,randperm(size(A,2),3000))=[]

카테고리

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