extending columns and rows of matrix

5 次查看(过去 30 天)
Hi I have a matrix like
a=[11 12 113 14
21 22 23 24
31 32 33 34
41 42 43 44]
and I want to extend it to
b=[11 12 13 14 0 0
21 22 23 24 0 0
31 32 33 34 0 0
41 42 43 44 0 0
0 0 0 0 0 0
0 0 0 0 0 0]
how can I do that with a one line command? thank you
[EDITED, Jan, code formatted]
  2 个评论
Jan
Jan 2012-12-29
@ss: Did you see, that there were no linebreaks in your question? I've formatted this, because it was not clear if a and b are vectors or matrices.
ss
ss 2012-12-29
they are matrix a is 4*4 and b is 6*6

请先登录,再进行评论。

采纳的回答

Jan
Jan 2012-12-29
Or:
a(6,6) = 0;
This fills the rest with zeros automatically.

更多回答(1 个)

Image Analyst
Image Analyst 2012-12-29
Try this
a = [a zeros(1, 14)];
  1 个评论
Image Analyst
Image Analyst 2012-12-29
If you have the Image Processing Toolbox, you might be interested in the padarray() function.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by