Add a zero row or help multiply these matrixes

When you take the difference of a column you are short one row. I would like to add a zero to the beginning of this output. I want to do this because I want to multiply two matrices and I can't do it if they are uneven.

답변 (1개)

Image Analyst
Image Analyst 2017년 6월 8일

0 개 추천

Not exactly sure what you want, but in general:
To prepend a row:
[rows, columns] = size(m);
row0 = zeros(1, columns);
col0 = zeros(rows, 1);
m2 = [row0; m];
To append a row of 0s:
m2 = [m; row0]
To prepend a column of 0s:
m2 = [col0, m];
To append a column of 0s:
m2 = [m, col0];

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2017년 6월 8일

편집:

2017년 6월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by