The using of "sum" in a script

Made a small script in which we pick 2 random numeric elements from the "box" (array with "0"s and "1"s). I want to make further steps depending on the sum of these elements, however Matlab doesn't execute the script with the following mistake (see the screenshot). Script proceeds with ">" and "<", but not "="

 Accepted Answer

one = is an assignment, two = is a test of equality
if sum(x) == 1
will fix this.

1 Comment

thx, did this the 2d time and it worked I tried this before but somehow it didn't help

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!