merging two matrix into a single one

4 次查看(过去 30 天)
Hi,
I have two matrices.
j =
1 2 3
0 0 0
0 0 0
k =
0 0 0
0 0 0
4 1 7
I need the following matrix
l =
1 2 3
0 0 0
4 1 7
How to do that? Thanks

采纳的回答

Matt Fig
Matt Fig 2011-6-15
J = [1 2 3;0 0 0;0 0 0];
K = [0 0 0;0 0 0;4 1 7];
L = max(J,K)

更多回答(1 个)

Walter Roberson
Walter Roberson 2011-6-15
J = [1 2 3;0 0 0;0 0 0];
K = [0 0 0;0 0 0;4 1 7];
L = J + K;
or
L = J; L(K<>0) = K(K<>0);
  5 个评论
Andrei Bobrov
Andrei Bobrov 2011-6-15
L(K~=0) = K(K~=0)
Hi Mohammad! "<>" -> "~=" analog in other languages
Walter Roberson
Walter Roberson 2011-6-15
Oops... the symbolics use <> and I've been answering questions about those again.

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by