Isn't this a duplicate?
If it's not your homework, you can use my solution:
a = [3 5 7 3 5 8 9 3 1 41 6];
[minDiff, index] = min(abs(c - s/2))
(If it is your homework, tag it as homework and find a different way. Don't turn in any of our solutions as your own or you may get caught for cheating.)