How to remove extra numbers to reduce size of vector?

조회 수: 1 (최근 30일)
Ammy
Ammy 2022년 3월 11일
댓글: Ammy 2022년 3월 11일
The following code removes extra number from the start of vector A if the size is not divisible by 3,
I want to remove extra numbers from the end of vector A.
A = rand(10000,1);
s = 3;
shortvector = A((end-s*floor(end/s)+1):end);

채택된 답변

KSSV
KSSV 2022년 3월 11일
A = rand(10000,1);
s = 3;
n = mod(length(A),s) ;
iwant = A(1:end-n) ;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by