行列要素の足し算

8 visualizaciones (últimos 30 días)
可野 谷上
可野 谷上 el 28 de Dic. de 2020
Respondida: Shunichi Kusano el 28 de Dic. de 2020
行の隣り合った要素を足して新たな行列を作りたいです。
例えば、
A=[1 2 3 4; 5 6 7 8; 9 10 11 12]
という3×4の行列があるとすると、
B=[1+2 2+3 3+4; 5+6 6+7 7+8; 9+10 10+11 11+12]
=[3 5 7; 11 13 15; 19 21 23]
という行列3×3のBを作りたいです。
よろしくお願いいたします。

Respuesta aceptada

Shunichi Kusano
Shunichi Kusano el 28 de Dic. de 2020
こんにちは。
B = A(:,1:end-1) + A(:,2:end);
でいけます。

Más respuestas (0)

Categorías

Más información sobre データ型 en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!