add new columns to the existing matrix

2 Ansichten (letzte 30 Tage)
mahesh chathuranga
mahesh chathuranga am 10 Sep. 2013
I have a 64*63 matrix.now i want to add new column to the end of the all existing 63 columns with all 0 values.i.e I want to make the matrix of 64*64

Antworten (1)

Andrei Bobrov
Andrei Bobrov am 10 Sep. 2013
Bearbeitet: Andrei Bobrov am 10 Sep. 2013
a - your array < 64 x 63 double >
out = [a zeros(size(a,1),1)];
or
a(64,64) = 0;
  3 Kommentare
Image Analyst
Image Analyst am 10 Sep. 2013
However, I'd use
out = [a zeros(size(a,1),1)];
in the first case, to get the number of rows and get rid of the warning message that's produced if you use size(a), which gives a 1x2 array.
Andrei Bobrov
Andrei Bobrov am 10 Sep. 2013
Oh! My typo. Thank you Image Analyst.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by