how to select last elements of a row vector?

43 Ansichten (letzte 30 Tage)
Tomaszzz
Tomaszzz am 8 Mär. 2022
Beantwortet: Davide Masiello am 8 Mär. 2022
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?

Akzeptierte Antwort

Torsten
Torsten am 8 Mär. 2022
j_last5 = j(end-4:end);

Weitere Antworten (1)

Davide Masiello
Davide Masiello am 8 Mär. 2022
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

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by