ANSWER:
If this is mathi, then your fasting is valid.
And in case you have wet dream during the day of Ramadan, then your fasting is valid as well.
But if you intend to ejaculate by masturbating or having sexual intercourse, then your fasting is not valid.