You can do it the way that
@Reiner ********
explained above but if you don’t want to go outside the country to change your visa when you arrive here, do your research online and use the farang learn Thai Facebook page to get some reviews from other students currently learning Thai at schools here. Most schools have their courses and fees displayed on their website and some will organise the education visa paperwork for you so you can apply at the Thai embassy in Portugal before you leave (this is what I did) I will say though if you are going to do it this way you must leave yourself enough time for the school to get the paperwork in order as they need a letter from the MOE in Bangkok before you can apply for this visa. If your school is based in BKK it shouldn’t be too long I would plan for about a month at least before you visit Thailand. If the school is outside BKK at least 2 months, as mine took nearly this long inc courier to my home Country and applying by post to the embassy.