Synthetic sine response
A 0.16 hertz sine drives G(s) = 1/(s² + 0.3s + 1) for 20 seconds at dt = 0.02. That tone sits near the plant’s natural frequency. Output noise is 0.03 with seed 12. Gain and phase can be read from one frequency.
Driven oscillator
u(t) = sin(2 π * 0.16 * t), G(s) = 1 / (s^2 + 0.3 s + 1)
What this page generates
Natural frequency 1 rad/s is 1/(2π) hertz, about 0.159. The input 0.16 Hz is aimed at that peak. For a lightly damped second-order system the magnitude is large near ω and the phase moves quickly there. One sine does not trace a whole Bode plot. It gives one point on it, plus the transient from rest. The first few cycles climb as the homogeneous solution dies. Later cycles are closer to a pure gain and phase shift of the input.
The input is amplitude 1 times sin(2π f t) with f = 0.16. It is not an angular-frequency input of 0.16 rad/s, which would be much slower. The denominator matches the step-response page, so the plant is the same object under a different force. Damping ratio 0.15 applies here too. Measurement noise uses seed 12, not seed 8, so the noise is not a copy of the step experiment.
RK4 holds each input sample constant for dt, a zero-order hold. At 50 samples per second and a 0.16 Hz tone there are hundreds of samples per cycle, so the hold is a small distortion. If you raise the frequency toward the Nyquist rate of the sample time, that distortion grows and this essay no longer describes the experiment. Stay near 0.16 Hz if you want the comparison with the natural frequency.
Report gain from the later cycles of output_clean, not from the noisy column and not from the first cycle. The file includes the input so you do not have to reconstruct the sine yourself. It remains synthetic data.
Generating rule
Driven oscillator
u(t) = sin(2 π * 0.16 * t), G(s) = 1 / (s^2 + 0.3 s + 1)
Check values
Worked numbers
Seed 12 produced 1001 rows from t = 0 to t = 20.00. The clean output peaks at 3.020 and ends at -1.040. The input changes value 1000 times. Those figures describe this seed only; they are not a laboratory trial.
Parameters and defaults
| Parameter | Default | Range | Effect |
|---|---|---|---|
| frequency | 0.16 Hz | ≥ 0 | Tone placed next to 1/(2π) Hz. |
| amplitude | 1 | finite | Scales the sine. The plant is linear, so the output scales with it. |
| plant | 1 / (s² + 0.3s + 1) | proper | Same coefficients as the step-response page. |
| dt / duration | 0.02 s / 20 s | duration > dt | About three cycles after the transient. |
| noise std | 0.03 | ≥ 0 | Sensor noise on y. |
| seed | 12 | unsigned 32-bit | Repeats the sensor noise. The sine does not use it. |
Python for this seed
Full script with mulberry32() & box_muller() available via Copy Python above
# SYNTHETIC DATA - generated by MockDataLab (mockdatalab.com)
# This file is synthetic and must not be presented as real measurements, clinical data, or results from a physical instrument.
# generator: control-transfer-function
# seed: 12
# G(s) = (1) / (s^2 + 0.3*s + 1)
# numerator (highest power first): 1
# denominator (highest power first): 1, 0.3, 1
# input: sine amplitude=1 frequency_hz=0.16
# integrator: RK4 with zero-order hold
# mulberry32() and box_muller() are included when you copy the full script.
SEED = 12
DT = 0.02
STEPS = 1000
NOISE = 0.03
A = np.array([[0.0, 1.0], [-1.0, -0.3]], dtype=np.float64)
B = np.array([0.0, 1.0], dtype=np.float64)
C = np.array([1.0, 0.0], dtype=np.float64)
D = 0.0
def input_at(i, t):
return (1.0) * math.sin(2.0 * math.pi * (0.16) * t)
def deriv(x, u):
return A @ x + B * u
def rk4(x, u, dt):
k1 = deriv(x, u)
k2 = deriv(x + 0.5 * dt * k1, u)
k3 = deriv(x + 0.5 * dt * k2, u)
k4 = deriv(x + dt * k3, u)
return x + (dt / 6.0) * (k1 + 2.0 * k2 + 2.0 * k3 + k4)
rng = mulberry32(SEED)
state = np.zeros(A.shape[0], dtype=np.float64)
time = np.empty(STEPS + 1, dtype=np.float64)
inp = np.empty(STEPS + 1, dtype=np.float64)
clean = np.empty(STEPS + 1, dtype=np.float64)
output = np.empty(STEPS + 1, dtype=np.float64)
for i in range(STEPS + 1):
t = i * DT
u = float(input_at(i, t))
y = float(C @ state + D * u)
time[i] = t
inp[i] = u
clean[i] = y
output[i] = y + (NOISE * box_muller(rng) if NOISE > 0 else 0.0)
if i < STEPS and state.size:
state = rk4(state, u, DT)
columns = ["time", "input", "output_clean", "output"]
data = np.column_stack([time, inp, clean, output])
Exercises
- EXERCISE 01Estimate gain and phase at a single frequency from the late record.
- EXERCISE 02Compare this steady wiggle with the step response of the same denominator.
- EXERCISE 03Show a class the difference between hertz and radians per second on a concrete file.
Questions
Why do the first cycles look smaller?
The state starts at rest. The particular solution has to grow in while the transient dies. Use a later window for the gain estimate.
Is 0.16 exactly 1/(2π)?
1/(2π) is about 0.15915. The box is set to 0.16, close enough to sit on the resonance and easy to type.
Does the sine consume the seed?
No. Only measurement noise does. A noise level of 0 yields a deterministic output for any seed.
Related
- step response of this same plant
- broadband binary input
- a cosine formula that is not a plant output
- edit the frequency
- sine-response CSV
- Static CSV for seed 12
SYNTHETIC DATA - generated by MockDataLab (mockdatalab.com). Do not present the download as a real measurement.