Eliminate rows from an array
Mostra commenti meno recenti
Hi everyone
How can I cut a 31450X1 array in order to obtain the same array with a dimension of 15725X1, eliminating the second half of rows from the original array? The array is a variable I'm working with, but I can't solve that problem. I tried it creating the next code:
LEN=length(data3);
for x=1:LEN
if x>(LEN/2)
ROW=LEN;
data3(ROW,:)=[];
end
end
Where data3 is the 31450X1 array, but the matrix index is out of range for deletion
Risposta accettata
Più risposte (1)
Mouhamed Niasse
il 12 Giu 2021
Hello, this is what you tried to achieve:
data3(1+length(data3)/2:length(data3),:)=[];
Try to run below example. Hope it helps you understand.
data3=ones(31450,1); % data3 initialized as row vector of size 31450x1
size(data3)
data3(1+length(data3)/2:length(data3),:)=[]; % Eliminate second half of rows
size(data3)
1 Commento
José Santos Pérez Leal
il 12 Giu 2021
Categorie
Scopri di più su Data Types in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!