Suppose we have matrix A like this:
10 5 8 6 2
A= 9 3 5 4 1
12 5 7 2 6
How can I choose a subset of A where there is no third column(for example)??
like this:
10 5 6 2
B = 9 3 4 1
12 5 2 6
I know I can say:
B = A(:,[1 2 4 5]);
but I need a better way
You can use
B = A(:,1:size(A,2)~=n);
with n
as selected column (see answer of @freude).
His solution also works fine in any case, but locial indexing (as here) should be faster than his approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With