Delete rows from an array
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ricardo López
am 15 Dez. 2020
Kommentiert: Image Analyst
am 15 Dez. 2020
Good afternoon
I have a long array of numbers, CEC (52560x1) and I would like to delete the rows in the following way:
r = 1:1:8760
t = 0:1:8759
CEC((2+6*t):(6*r))
I tried to set it into a loop by:
for r = 1:1:8760
for t = 0:1:8759
CEC((2+6*t):(6*r)) = [];
end
end
But it is not working for me. Any ideas?
Thank you!
3 Kommentare
Image Analyst
am 15 Dez. 2020
Please give some actual numbers. For example, what indexes represent the first set of rows to delete, and the second set of rows to delete?
Akzeptierte Antwort
Weitere Antworten (1)
SHIVAM KUMAR
am 15 Dez. 2020
Bearbeitet: SHIVAM KUMAR
am 15 Dez. 2020
Your code will work like this if used on 1 D array .
CEC((2+6):end) = [0];
If you are using that your array shall be 52560X52560.
then you can use
for r = 1:1:8760
for t = 0:1:8759
CEC((2+6*t),(6*r)) = [0]; %Use a comma
end
end
1 Kommentar
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!