Efficient indexing. Index array generating.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Christian Tieber
il 2 Feb 2021
Commentato: Christian Tieber
il 3 Feb 2021
data and array1 are given. I am looking for a more efficient way to generate index. It should be a one-liner.
Thanks in Advance!
data = 1:1000;
array1 = 1:10:101
array2 = array+2
index = [];
for i = 1: numel(array1)
index = [index; array1(i):array2(i)];
end
data2 = data(index)
0 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrices and Arrays in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!