MATLAB Answers

0

Change the certain element after comparison of two arrays

Asked by Maksim Tiurin on 13 Jun 2019
Latest activity Answered by Joel Handy on 13 Jun 2019
there is a string of 8 numbers, and a string filled with zeros (of the same length). I need to check the first string for the presence of zeros in it, and if there is a zero there, then it is necessary that in the second string the same element is changed to 1.
For example
B = [0 0 0 0 0 0 0 0]
A = [1 2 3 4 5 6 7 0]
then check A for the presence of zeros and change B to the B = [0 0 0 0 0 0 0 1]
Perhaps this is a stupid question, but I have not yet found an answer, please help.

  0 Comments

Sign in to comment.

1 Answer

Answer by Joel Handy on 13 Jun 2019
 Accepted Answer

B = A == 0;

  0 Comments

Sign in to comment.