Hello Friend, Good that you are seeking a help here. Yes, you are right. Anxiety or depression can cause such physical dysfunction. We call it psychosomatic disorder i.e physical disorders caused by emotional imbalance.
Be positive. You can address by taking a professional help of psychology expert, who can guide you to managing your anxiety and stress levels.
Next Steps
Consult me online or through Practo for further detailed evaluation and suitable recommendation.