insert zero column in a m×n matrix ?

65 views (last 30 days)
hello, i want to insert a zero column in the beginning of a matrix. say for example, if i have 5×5 matrix. if i want to insert zero column in the beginning then the matrix will be 5×6 matrix, so now the first column in this matrix will be zeros. how do i do it? need some help. Thank you.

Accepted Answer

Sven
Sven on 2 Nov 2011
For a given matrix A:
A = rand(5,5);
Using square braces to concatenate:
A_zeros = [zeros(size(A,1),1) A];
Using the cat() command:
A_zeros = cat(2, zeros(size(A,1),1), A);

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!