get a matrix of only zero

1 回表示 (過去 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 日
A = zeros(2,5)

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 Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by