How to simplify the for loops and if statement in this code

How to simplify for loops and if statements.

1 Comment

Please restore the original post -- there's no context for others going forward now.

Sign in to comment.

 Accepted Answer

Straightahead w/o trying to save some recomputations that could be done by complements--
k=[sum(A==B & A==0,'all') sum(A==B & A~=0,'all');sum(A~=B & A==0,'all') sum(A==B & A==1,'all')];

More Answers (0)

Categories

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

Commented:

dpb
on 23 Jun 2020

Community Treasure Hunt

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

Start Hunting!