"What's the matter with you?" is sometimes seen as a bit rude, as it is asking what is WRONG with you as a person (normally used when someone does something very wrong or rude). "What's the matter?" is much better, as it's asking what is wrong with the situation, not the person.
Perhaps the best best question to ask in a situation when you're concerned about someone would be "Are you ok?"