Since Martinez is a staffed station, you can buy a ticket at the station. However, tickets can sell out at times, so it is best to purchase a ticket ahead of time.
I agree with Joshua, better to have your ticket in advance if your trip is to be guaranteed.
I believe there are electronic ticket kiosks and staff who both sell tickets.
Thanks! Your answer is awaiting moderation.