MATLAB: How to add a column to a matrix

matrix manipulation

I created a 30×30 matrix and now I want to delete the 1st column of data and add another column replacing the deleted column (which should not replace the same column), so I again get a matrix of size 30×30. I am successful in deleting the 1st column but cannot add another column.

Best Answer

Arr = rand(30,30);
%Delete first column
Arr(:,1) = [];
NewCol = rand(30,1);
%Add new column
Arr = [Arr NewCol];