Yes, you gain experience all right, but the FACT is, you should have
gained that experience in your PRACTICE sessions. All you find out
by getting beat by a better player is that THERE WERE SITUATIONS
that you were not prepared for. What it tells you is, that you did not
have enough imagination in practice to ever imagine the situation
coming up. It also tells you that you line of thinking about the game
is NOT QUITE RIGHT, which caused you to make mistakes which lost
the match for you. It also tells you, you did not know your opponents
game before playing him, therefore you were UNPREPARED for the match.
Read 'The Art of War' by Sun Tzu, that's the best advice I can give you.