MATLAB Answers

Binary value convert.

조회 수: 2(최근 30일)
Noman Abir
Noman Abir 2021년 1월 2일
댓글: Ameer Hamza 2021년 1월 2일
I have a binary bit sequence A = [0 1 0 1;1 0 0 1; 0 0 0 1; 1 0 0 1]; How can i convert all the 0 values into -1.??
The final output will become as A = [-1 1 -1 1;1 -1 -1 1;-1 -1 -1 1;1 -1 -1 1];

채택된 답변

Ameer Hamza
Ameer Hamza 2021년 1월 2일
Read about logical indexing
A = [0 1 0 1;1 0 0 1; 0 0 0 1; 1 0 0 1];
A(A==0) = -1;
  댓글 수: 3
Ameer Hamza
Ameer Hamza 2021년 1월 2일
Yes, it is better to post your question on this forum so that you have a better chance of getting any help, and the answers will also be helpful for others.

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

추가 답변(0개)

태그

제품


릴리스

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by