If your doctor diagnoses erectile dysfunction, they will also examine you to find out the root cause. Likely, they'll give you a physical exam where they'll check your vitals, as well as your genitals.
They may also give a psychological exam, where they'll ask you questions about your health history, including your sexual and mental health.
The results of these exams will help determine whether your erectile dysfunction is physical or mental.