get a matrix of only zero

조회 수: 5 (최근 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 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