Doctor asked me to produce semen for analysis, so I had to masturbate

The doctor treating me asked me to produce some semen and told me that this was imperative at which I felt inconvenienced and coerced such that I gave him some semen for the sake of the test.

Whilst fasting, he is aroused then masturbates

If a Muslim’s desire is aroused during the day in Ramadhaan and he finds no recourse but to masturbate, does this nullify his fast and does he have to make up for this day and make any expiation for this act?