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

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 comentarios

Maybe I'm not understanding the requirements but the are no bold values in Matlab. You made them bold in the text editor but in Matlab they are just 1s and 0s.
I know that I can't make them bold in Matlab. I just put them here as bold to simplify the question and to show you the difference of bits between V and C that's all
> 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).
Exactly yes, and then correct the bold bits of V in order to obtain them equal to C

Iniciar sesión para comentar.

 Respuesta aceptada

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 comentarios

Sorry, but that is not what I search
Hi Afluo,
Why does this not work for you?
You should be able to write a simple for loop this should be able to point to the miss-matched locations in diff_Check and change the value accordingly. What is the problem? Am I missing a further complexity?
Christopher
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
Thank you so much. It works

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 18 de Mzo. de 2021

Comentada:

el 18 de Mzo. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by