Filter löschen
Filter löschen

Finding the largest index in an array that is divisible by a certain number

7 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 23 Mai 2013
divisor = 3;
new_array = old_array(1 : end - mod(end,divisor));

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by