how can i creat an sub array with last n number of column of an array?
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
jakaria babar
am 21 Dez. 2018
Kommentiert: jakaria babar
am 22 Dez. 2018
s =
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
a =
3 4 5
8 9 10
13 14 15
i am not getting 'a' using the code
A=s(1:n;end-n-1:end).
0 Kommentare
Akzeptierte Antwort
madhan ravi
am 21 Dez. 2018
Bearbeitet: madhan ravi
am 21 Dez. 2018
By indexing you can achieve it :
s= [1 2 3 4 5
6 7 8 9 10
11 12 13 14 15];
n = 3 ; % last n number of columns
a = s(:,n:end)
Gives:
a =
3 4 5
8 9 10
13 14 15
0 Kommentare
Weitere Antworten (2)
Siehe auch
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!