If it was one student or a small group of students, try to find them the same day. If that isn't possible, plan to seek them out as soon as possible the next day, or perhaps use a school-approved email to contact them to let them know you would like to process what happened at school. Don't put too much in the email, just let them know you would like to talk in person regarding the incident. When you find them, simply apologize. Short and sweet. Tell them you feel you may have been unfair, and you are sorry that you scolded them. Don't dwell on the apology, you are setting an example for how to apologize and letting them know that even adults make mistakes and need to apologize sometimes. After your apology, process whatever it was that initially upset you. Have a conversation about it (perhaps the way you should have in the first place!). Quite possibly the student is also at fault in the situation, and you may receive an apology back at this time. If not, don't dwell on that or expect it and therefore wait for it to come. Redirect your focus to finding the most appropriate consequence for what was happening in your class. But be careful--don't consequence the student if there truly isn't a reason. Most students will respect you greatly for acknowledging if you were unfair, and they will try even harder to please you in the future. They will see you as a "real" person and not a controlling power-hungry adult.
If it was an entire class, get ready to feel vulnerable! If you aren't ready for that, perhaps you may want to confide in a social worker or trusted veteran teacher/administrator to help you out. Starting this conversation might be difficult. If you can, you may want to reach out to a few students ahead of time and let them know you are planning to apologize to your class as a whole, but you felt they would appreciate a personal apology first. See the paragraph above for tips...and now back to the class apology. You might feel more "real" if you get yourself in a more conversational setting. If all of your students are sitting, perhaps you could grab a stool and sit as well. I find that it changes the tone of what I'm saying when I'm sitting (I get more relaxed). This will be a hard conversation. That might be the easiest thing to say first: "Guys, this is a hard conversation for me to have. But, you deserve to hear it. Yesterday, I should have handled the situation in class differently. I'm sorry for what I said to you. It wasn't kind, and I hope you accept my apology. What I was trying to say was ...." and then say what you should have said the first time around. Again, don't dwell on the apology part, move on to processing what happened in a more appropriate way.
You'll probably have your students eyes glued on you in a way you've never had before. They are seeing you as a real person, with real emotions and real feelings at this moment. Don't let it last too long--get back to teaching soon! You are their teacher and they need to see you as the authority in the room. Just because you have a heart-to-heart does not mean you lose authority. More than anything else, if you handle it correctly, they will learn a life lesson from your apology.