# How can I extract the logical value in a loop (various columns)?

7 views (last 30 days)
DulceEien on 27 Aug 2021
Commented: DulceEien on 2 Sep 2021
Hello, I'm runnning my code and my logical value is running, what I would like to do is exctract the logical value for several columns (from column 5 to 10) can I do it in a loop or I have to name various variables and then join them?
idx=logical(idx);
[X,Y]= meshgrid(T2.length,T.length);
C = X(idx);
D = Y(idx);
delta = (C - D);
t = table(D,C,delta);
T2 and T are the table were I'm talking the values lenght is in the 5th column and I would like to do the same for column 6,7,8,9,10 is it possible without naming them again? and then do the substraction?
have a nice Friyay

Kevin Holly on 27 Aug 2021
Edited: Kevin Holly on 27 Aug 2021
is this what you are looking for?
idx=logical(idx);
for i = 5:10
[X,Y]= meshgrid(T2.(i),T.(i));
C = X(idx);
D = Y(idx);
delta = (C - D);
T(i-4).table = table(D,C,delta);
end
DulceEien on 2 Sep 2021
thank you so much