hi.. thanks for writing..i have understood your concerns..
you can understand that it is just a
anxiety of sexual performance and fear of failure because in the past it had happened..
you do not have any problems while masturbating, so this all is related to anxiety and stress, purely psychological..
you shud try to ocntrol your anxiety by exercise,
meditation, relaxation exercise..you can talk about this issue with your girl friend also, you shud not feel shame in talking to her..
erectile dysfunction due to anxiety is very common..and first time it causes problem with everyone..
if you can not find solution on your own then you shud
consult a psychiatrist and tell your problems.,he will help you in controlling your anxiety and will guide you through the treatment..
you shud undergo
sex therapy..spend more time in foreplay before going for penetrative sex..
i hope this will be helpful to you..best of luck..