Whether exercise or medication is best for depression or anxiety depends on several factors.