MATLAB: Load specific columns of a variable and sabe

mathematicsMATLAB C/C++ Math LibrarySymbolic Math Toolbox

I define variable
B = magic(10);
If I want to save the first column of B in a differnt variable, I can do this
firstColB = B(:,1);
But what if I want to save columns 1, 3 ,5 7, 9. How can i save those specifc columns to a variable A
A = B(:,?)
Thanks!

Best Answer

Try this:
A = B(:,1:2:9)
or this:
A = B(:,[1 3 5 7 9])