How to delete even Index from array and replace zero at the end MATLAB
조회 수: 6 (최근 30일)
이전 댓글 표시
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
채택된 답변
Jan
2022년 3월 3일
"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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!