Hello for better understanding you need to know somethings about erectile dysfunction. Erectile dysfunction is the inability to get and keep an erection firm enough for sex.
Having erection trouble from time to time isn't necessarily a cause for concern. If erectile dysfunction is an ongoing issue, however, it can cause stress, affect your self-confidence and contribute to relationship problems. Problems getting or keeping an erection also can be a sign of an underlying health condition that needs treatment.
Sometimes, treating an underlying condition is enough to reverse erectile dysfunction.
Few causes for erectile dysfunction include, Metabolic syndrome — a condition involving increased blood pressure, high insulin levels, body fat around the waist and high cholesterol, Peyronie's disease — development of scar tissue inside the penis, Certain prescription medications, tobacco use, alcoholism and other forms of substance abuse, sleep disorders, injuries that affect the pelvic area and psychological things include -
Depression, anxiety or other mental health conditions, stress, relationship problems due to stress, poor communication or other concerns.
So to find the cause some questions needs to be asked and some tests may be looked upon. There are treatments available for erectile dysfunction, so no need to worry, consult a psychiatrist first to find the cause then the treatment.