I have any matrix I need a code such that if the absolute value of a value in the matrix less than 3, then this value equal to zero.
for example if i have the matrix:
A=[-1,4,3;1,5,-7;3,-2,9]
the answer will be:
B=[0,4,0;0,5,-7;0,0,9]
Thank you

 채택된 답변

per isakson
per isakson 2015년 4월 27일
편집: per isakson 2015년 4월 27일

0 개 추천

Try
>> B = A;
>> B(abs(A)<=3) = 0
B =
0 4 0
0 5 -7
0 0 9
However, -7 isn't it "less than 3"?

추가 답변 (1개)

ateq alsaadi
ateq alsaadi 2015년 4월 27일

0 개 추천

Thank you it works.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2015년 4월 27일

편집:

2015년 4월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by