Remove random columns from a big matrix?

1 vue (au cours des 30 derniers jours)
stelios loizidis
stelios loizidis le 6 Août 2019
Commenté : Adam Danz le 6 Août 2019
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!!

Réponse acceptée

Adam Danz
Adam Danz le 6 Août 2019
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 commentaires
stelios loizidis
stelios loizidis le 6 Août 2019
I tried it and it works fine. Thank you very much!!!!!
Adam Danz
Adam Danz le 6 Août 2019
Glad I could help!

Connectez-vous pour commenter.

Plus de réponses (1)

madhan ravi
madhan ravi le 6 Août 2019
B(:,randperm(size(A,2),3000))=[]
  1 commentaire
stelios loizidis
stelios loizidis le 6 Août 2019
Thank you very much!!!!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by