get a matrix of only zero

2 次查看(过去 30 天)
Salvatore Mazzarino
Salvatore Mazzarino 2012-11-10
How can I get a mattrix made of only zeros?
For example I have this matrix
[2 4 0 5 6 0]
I would get a matrix made of only zeros

回答(4 个)

Matt Fig
Matt Fig 2012-11-10

Walter Roberson
Walter Roberson 2012-11-10
编辑:Walter Roberson 2012-11-10
NewMatrix = 0 .* OldMatrix;
(Mind you, this has a problem if any of the entries were infinite or NaN)

Matt J
Matt J 2012-11-10
newmatrix=zeros(size(oldmatrix));

Matt J
Matt J 2012-11-10
yourmatrix(:)=0;

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by