Can I add fsolve to the initval block?

Hello everyone,
I am wondering if there is a way to automate my search for initial steady state guesses as I vary my parameters.
The model I’m working on is fairly complex and I cannot solve for its steady state exactly using _steadystate.m file, so instead must use initval block. The initial guesses change a bit as I vary different parameters, and the .mod file is very sensitive to having starting values “close enough” to the actual steady state. If I’m not careful, I keep getting the message “Impossible to find the steady state (the sum of square residuals of the static equations is 0.0007). Either the model doesn’t have a steady state, there are an infinity of steady states, or the guess values are too far from the solution.”
To fix this issue, every time I make a parameter change I have to manually run a companion Matlab code that uses fsolve to solve a small-ish system of nonlinear equations from which the rest of the starting guesses derive. I then copy and paste these guesses into my .mod file and let dynare’s own nonlinear solver do its magic to get me the new steady state.
Obviously, this will get very tedious as I start running simulations over large grids of parameter values. It seems that I can’t directly call fsolve from the initval block of my .mod file. Is there another workaround?
Thank you!

initval in a stochastic context is just Dynare syntax for filling the contents of oo_.steady_state. For your problem, you should directly assign these values.