I'm a medical student and for certain, telling you to "get horny and masturbate" is not appropriate. If you complained about erectile problems or penile problems which can only been seen in erection, he might very well ask you to make yourself erect. As for other exams, erection is not needed at all, even if you're a male and he wants to take some sample of your prostate fluid (can be done by digital prostate massage).