How to delete even Index from array and replace zero at the end MATLAB
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have the code which delete 5% of random index from the dataset and add zero at the end .
i just want to delete even index sample from the array and add zero at the end
discard= delete the random sample from array
load('datasetvalue.mat')
[M,N] = size(dataset) ;
percentageMP=5;
size_MP=round(percentageMP/100*N);
Discards=zeros(M,size_MP);
for i=1:M
MP=dataset(i,:);
discard=randsample(N,size_MP);
MP(discard)=[];
MP(:,end+1:N)=0;
MPV(i,:)=MP;
Discards(i,:)=discard;
end
0 Commenti
Risposta accettata
Jan
il 3 Mar 2022
"delete even index sample from the array and add zero at the end"
Maybe:
X = rand(10, 10); % Arbitrary test data
X(2:2:end, :) = []; % Delete rows with even indices
X(10, 10) = 0; % Fill with zeros implicitly
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!