필터 지우기
필터 지우기

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