Finding the largest index in an array that is divisible by a certain number
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
Given an nx1 array, I'm trying to get matlab to determine the largest index value which is divisible by a number (say 3), and then have matlab truncate the array to that point.
Any suggestions?
Thanks, Charles
0 Commenti
Risposta accettata
Walter Roberson
il 23 Mag 2013
divisor = 3;
new_array = old_array(1 : end - mod(end,divisor));
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!