Hello,
If you are having fine erections during masturbation then the cause of erectile dysfunction seems psychological in nature. You should go for a clinical examination and blood test to check for testosterone level etc for diagnosis. You should avoid alcohol and smoking, take healthy food, do sensual exercise, counseling done by a psychologist. You can do some regular exercise in form of yoga, shed weight and have a proper sleep.
It is very difficult to precisely confirm a diagnosis without examination and investigations and the answer is based on the medical information provided. For exact diagnosis, you are requested to consult your doctor. I sincerely hope that helps. Take care and please do keep me posted on how you are doing.
Hi why not take a break from masturbating or cut it down , if you do you may benefit from it , Take care ,