MATLAB: How to simplify the for loops and if statement in this code confusionmatrixforfor loopif statement How to simplify for loops and if statements. Best 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')]; Related SolutionsMATLAB: Sum inside a for loob b = 0;for k = 1:5 a = price1 * k; b = b + sum(a); % Or b = b + a?end MATLAB: Replacing while loop with break command clc;clear;close all; limit=210; k = 0; sum = 0; while sum <= limit k=k+1; sum = sum + k; end sum n=k Related QuestionCounting how many times a loop loops.How to simplifyWriting a loop instead of sumMatlab simplify boolean expression
Best Answer