Hello dear
Understand your concern
Masturbation is just like sex, it does not cause
erectile dysfunction so first avoid stress as stress itself causes erectile dysfunction.
How an you tell that you have erectile dysfunction and impotence just before sex. I think you have sexual anxiety. Better to avoid thinking about your problem. If you have excessive thought you can consult the psychiatric/
urologist to diagnose your cause after proper investigation like semen examination, while body check up , blood sugar. Noctural penile
tumescence test, and color doppler like investigation.
Doctor give you following advice:
Cognitive behavior and
counselling therapy, be relax while doing sex, start pelvic exercise (kegel's exercise), avoid smoking and alcohol, use condoms during sex, engage more in foreplay before going to intercourse, take healthy diet and fresh fruits, antioxidant rich item (co Q tablet and almond), tablet gonadil f and revital tablet, be positive and creative.
If problem persist after sex, you can sildenafil and paroxentine 30minutes before sex but after proper evaluation by doctor.
start regular morning walk and medication for 45-60 minutes everyday.
Hope this may help you
Best regards
Dr. Sagar