MATLAB: Issue with 3Sum problem!

3sumloop problem

Alright so I took some stuff out and now I'm down to this. For some reason though, it's just coming up with random numbers from the array instead of using them to find a 1D array which adds to zero. I think what the issue is, is that it's not using the integers to try and find where T would equal zero.
F = [-5,-4,-3,-2,-1,1,2,3,4,5];
for T = @(a,b,c) (a + b + c);
a = randsample (F,1);
b = randsample (F,1);
c = randsample (F,1);
if T(a,b,c) == 0
disp [a b c]
end
end

Best Answer

Your line
for T = @(a,b,c) (a + b + c)
does not really specify a loop. What you want is to find some a, b, and c whose sum is 0, so you need to loop through a, b, c. For example, if you want to do it 10 times, you can do
F = [-5,-4,-3,-2,-1,1,2,3,4,5];
T = @(a,b,c) (a + b + c);
for m = 1:10
a = randsample (F,1);
b = randsample (F,1);
c = randsample (F,1);
if T(a,b,c) == 0
disp([a b c])
end
end