how to select last elements of a row vector?

조회 수: 22 (최근 30일)
Tomaszzz
Tomaszzz 2022년 3월 8일
답변: Davide Masiello 2022년 3월 8일
Hi all,
I have a row vector:
j = [593,660,725,790,854,919,984,1050,1118,1184, 1300, 1400, 1500, 1600]
I want to select last 5 elements.
j_last5 = j(1,end-5);
gives me 1118
but I want : j_last 5 = [1184, 1300, 1400, 1500, 1600]
Can you help please?

채택된 답변

Torsten
Torsten 2022년 3월 8일
j_last5 = j(end-4:end);

추가 답변 (1개)

Davide Masiello
Davide Masiello 2022년 3월 8일
j = [593,660,725,790,854,919,984,1050,1118,1184, 1300, 1400, 1500, 1600];
j_last5 = j(end-4:end)
j_last5 =
1184 1300 1400 1500 1600

카테고리

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