Compare cells of different columns
Show older comments
Hi, I need to compare the data from columns 1, 2, 3 (where a particular option is located) to the column 4 (what answer was received). If the pair tested matches (e.g. cell 1,1 vs 1,5) I want to output the values located in the same row but in columns 5 and 6. If this is not possible, I just need it to show either a 1 or a 0. For the later I tried the following code:
gmax = [1;2;3;1;2;3];
pmax = [2;3;1;2;3;1];
lmin = [3;1;2;3;1;2];
response = [1;1;2;1;3;2];
start_time = [2.45; 6.32; 8.21; 10.12; 13.09; 16.7];
RT = [2.7433; 2.2333; 3.4532; 2.9919; 3.0011; 2.5509];
T = table (gmax, pmax, lmin, response, start_time, RT);
A = zeros (6,1);
B = zeros (6,1);
C = zeros (6,1);
for j = 1 : 6
A(j,1) = isequal (T(j,1), T(j,5));
end
for j = 1 : 6
B(j,1) = isequal (T(j,2), T(j,5));
end
for j = 1 : 6
C(j,1) = isequal (T(j,3), T(j,5));
end
Can you point me what am I doing wrong? It always returns 0, even if the pair matches. Many thanks
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!