How Would I create a matrix which contains the first and last m columns of another matrix?

1 view (last 30 days)
Assume that n>2m

Answers (1)

Benjamin Kraus
Benjamin Kraus on 12 Feb 2016
Lets say you have an M-by-N matrix, and you wanted the first K and last K columns:
m = 10;
n = 20;
k = 3;
A = rand(m,n);
Asub = A(:,[1:k (end-k+1):end]);

Community Treasure Hunt

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

Start Hunting!