Engine stopping in idle & RPM junmps around

I have a Mazda3-2004. My battery died yesterday. I baought a new battery & hooked it up. After changing the battery whenever I put my car in neutral(I have a stick shift) at a traffic signal or stop sign the RPM fluctuates & the car shuts. I can easily restart it. I was wondering if this is anyhow connected to the batteries, because before I changed the batteries there was no issue at all.

Please advice

Let it sit and idle for ten minutes and see if it “relearns” and goes back to normal.