When I have sudden opposite emotions like that I try to track down what I was thinking/what was being discussed or what I was reading and see if there's a reason. I will be happily reading a good book and suddenly find myself in front of the refrigerator

for example, so I go back to what I was reading and find it was something that made me think of something that was anxiety producing.