How can I change the value of some elements within a matrix

조회 수: 3 (최근 30일)
Lala
Lala 2020년 1월 11일
댓글: Ajay Kumar 2020년 1월 11일
Please, I am doing an elememt wise inverse of a matrix, the goal here is for any value that is infinity to be converted to 0. The code below is what I have come up with, but it is not giving me the desired results.
Inf 0.3333 0.1667
>> B =[0, 3, 6]
C= 1./B
if C == Inf
disp(0)
elseif C ~= Inf
disp(C)
end

채택된 답변

Ajay Kumar
Ajay Kumar 2020년 1월 11일
B =[0, 3, 6];
C= 1./B;
C(isinf(C))=0
  댓글 수: 2
Lala
Lala 2020년 1월 11일
It worked. Thank you!
Ajay Kumar
Ajay Kumar 2020년 1월 11일
You're Welcome.
Just a small suggestion. Try to search for the question once before asking it. I'm sure that there are many similar questions on the forum already.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by