Requesting guidance on the proper vectorization methods for combinations of if statements within for loops. An example of the format referenced is included below. Code is utilizing a painful combination of if statements nested within for loops and appropriate vectorization is the only way in which this will run efficiency
X = zeros(1000,1)C = 1:10for A = 1:10 for B = 1:10 if C = 1 X(A*B*C) = 1; elseif C = 2 X(A*B*C) = 2; else X(A*B*C) = 3; end endend
Best Answer