Detect the error position in a vector and correct it (Matlab)

조회 수: 3 (최근 30일)
Afluo Raoual
Afluo Raoual 2021년 3월 18일
댓글: Afluo Raoual 2021년 3월 18일
Dear members;
I have the code word C of length 'M' and I have also the received vector V after decoding of the same length 'M' as C
For example:
V=[1 0 0 1 0 1 0 1 0 0]
C=[1 1 0 1 0 0 0 1 0 0]
I want firstly detecting the position of each bold bit of V and than correct it by adding 1 to those bits (because in mod2: 0+1=1 and 1+1=0) in order to obtain V=C
How can I do that please
  댓글 수: 4
Adam Danz
Adam Danz 2021년 3월 18일
> I want firstly detecting the position of each bold bit of V
Ah, so what you really want to do is find the index of the vector where V(i) is not equal to C(i).
Afluo Raoual
Afluo Raoual 2021년 3월 18일
Exactly yes, and then correct the bold bits of V in order to obtain them equal to C

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

채택된 답변

Christopher McCausland
Christopher McCausland 2021년 3월 18일
Hi Afluo,
You can try something like the below to assess where the diffrences between the arrays are; after this just cycle to these locations and change the value as you need.
I hope this helps,
Christopher
V=[1 0 0 1 0 1 0 1 0 0]
C=[1 1 0 1 0 0 0 1 0 0]
diff_Check = V ~= C;
  댓글 수: 4
Adam Danz
Adam Danz 2021년 3월 18일
편집: Adam Danz 2021년 3월 18일
I agree with Christopher McCausland , this does describe what you want to do but is missing the final step which is quite straightforward and something you could fill in yourself,
V=[1 0 0 1 0 1 0 1 0 0];
C=[1 1 0 1 0 0 0 1 0 0];
V(V~=C) = V(V~=C) + 1;
mod(V,2)
ans = 1×10
1 1 0 1 0 0 0 1 0 0
Afluo Raoual
Afluo Raoual 2021년 3월 18일
Thank you so much. It works

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

추가 답변 (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