Hello Friends,
I have the following code:
P = [1 , 0, 2]; AB = [1, 2, 3]; CD = [4, 5, 6]; EF = [7, 8, 9];M = {[AB], [CD], [EF]};for i=1:length(M) P1 = P(M{i}~=0); t = M{i}; M2 = t(M{i}~=0); if ~any(strcmp(M, AB)) f = f(AB); elseif ~any(strcmp(M, CD)) f = f(CD); elseif ~any(strcmp(M, EF)) f = f(EF); endend
I am trying to run for loop for each i . The problem is if loop. The loop iterates only the 1st if statement for AB; it does not go to elseif statement for CD and EF. I realize the problem could be the way I am using strcmp, but then, I do not know how to do it. Here all matrices/functions are taken just for illustration purpose. They could be anything.
I will appreciate any advice!
%% Below I have given the modified code after Guillaume's suggestion. Please see code below for actual problem.
Best Answer