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

7 次查看(过去 30 天)
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

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by