Hi. I hope this question is placed in the proper category.
I have studied the DynamicalSystems.jl guidelines also followed in a very useful video by Datseris (Intro to dynamical systems in Julia - YouTube).

Suppose I have the code below, which is a slightly modified version of the first system that appears in the Datseris’s guide. My question is: how can I change a parameter like A (in the system below) after period 20 for example. That is, in the code below, how can I have parameter A equal to 1 in periods 1 to 19, and then, starting in period 20, the parameter A becomes 1.02.
I have tried to do that with various forms of “for” loops but my code has not worked.
Thanks in advance for your help.
This is the code:

using DynamicalSystems
using Plots
function henon_rule(u, p, n)
x, y = u # system state
A, a, b = p # system parameters
xn = A - ax^2 + y
yn = bx
return SVector(xn, yn)
end

May be my post was not very clear. I will try to explain a bit more.
What I would like to do is increase the value of a parameter starting in some period. The idea is to find the number of periods that it takes the system to reach a new steady state after the shock (I mean, after the increase in the parameter).
Below is the code I am using on a system, with a “for” loop.
The problem is that the increase in the parameter “E” is not shown in the plot. Any help will be appreciated.

using DynamicalSystems
using Plots

function test(u, p, n)
x, y = u
a, b, c, d, E = p
xn = ax + by
yn = cx + dy + E
return SVector(xn, yn)

Thank you very much for the suggestion.
From what I could see, the “callbacks” may be used in DifferentialEquations.jl or in DynamicalSystems.jl, but only for continuous systems. The system I am trying to simulate is discrete (what I mean is that it is a system of difference equations).
Thanks again.

I just realized that the code was incorrectly formatted. I should have used backticks.
This is the way it the code should look:

using DynamicalSystems
using Plots
function test(u, p, n)
x, y = u
a, b, c, d, E = p
xn = a*x + b*y
yn = c*x + d*y + E
return SVector(xn, yn)
for n=[400:500]
E=2.5
end
end
p = [1.0, 0.1, -0.01, 0.98, 0.025]
u0 = [0.0, 0.0]
ds = DiscreteDynamicalSystem(test, u0, p)
tr = trajectory(ds, 500)
plot(tr[:,1], label="x", xlabel="t", ylabel="Value of x, y", title="Test")
plot!(tr[:,2], label="y", xlabel="time")

I ran the following code, based on the suggestion to use the “callback” option. The code ran just fine, but the discontinuity does not show in the data or the plot. This is the code:

using DynamicalSystems
using Plots
function test(u, p, n)
x, y = u
a, b, c, d, E = p
xn = a*x + b*y
yn = c*x + d*y + E
return SVector(xn, yn)
end
p = [1.0, 0.1, -0.01, 0.98, 2.5]
u0 = [0.0, 0.0]
ds = DiscreteDynamicalSystem(test, u0, p)
tr = trajectory(ds, 500)
condition(u,n,integrator) = n==400
affect!(integrator) = integrator.p[5] += 90.5
cb = DiscreteCallback(condition,affect!)
tr = trajectory(ds, 500, callback=cb,tstops=[400])
plot(tr[:,1], label="x", xlabel="t", ylabel="Value of x, y", title="Test")
plot!(tr[:,2], label="y", xlabel="time")

The code above generates this plot:

As may be observed in the figure, there is no bump or discontinuity in period 400.