Could be both. Most commonly men who have sudden onset of ED have inhibition as a result of some event- anxiety, pain, distraction, alcohol, fatigue. But there may also be excessive nerve tone expressed by the brain which contracts the blood vessels making an erection harder to obtain. This can be psychologically and/or physically activated. Either way it's complex and it the problem persists visit a urologist.
Erectile dysfunction. In a case like yours, top of the list of things to consider is drug side effect: Did this follow the start of a new medication. E.g. beta-blockers (propranolol, atenolol, metoprolol etc) are well known to cause this.