You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- `w::AbstractVector{<:Real}`: Frequency vector (rad/s)
57
+
58
+
# Returns
59
+
- `sys_fr`: Complex frequency response array of size `(ny, nu, length(w))`
60
+
61
+
See also [`freqresp!`](@ref), [`evalfr`](@ref), [`bode`](@ref), [`nyquist`](@ref).
62
+
63
+
# Examples
64
+
```julia
65
+
using ControlSystemsBase
66
+
sys = ss([-1 0; 0 -2], [1; 1], [1 1], 0)
67
+
w = exp10.(LinRange(-2, 2, 200))
68
+
resp = freqresp(sys, w)
69
+
```
54
70
"""
55
71
@autovec () functionfreqresp(sys::LTISystem, w_vec::AbstractVector{W}) where W <:Real
56
72
te =timeevol(sys)
@@ -299,12 +315,29 @@ end
299
315
mag, phase, w = bode(sys[, w]; unwrap=true)
300
316
301
317
Compute the magnitude and phase parts of the frequency response of system `sys`
302
-
at frequencies `w`. See also [`bodeplot`](@ref)
318
+
at frequencies `w`. The frequency response is evaluated as `G(jω)` for continuous
319
+
systems and `G(e^{jωT})` for discrete systems.
320
+
321
+
# Arguments
322
+
- `sys::LTISystem`: The system to analyze
323
+
- `w::AbstractVector`: Frequency vector (rad/s). If omitted, a default frequency range is used.
324
+
- `unwrap::Bool`: If true (default), apply phase unwrapping to avoid discontinuities
325
+
326
+
# Returns
327
+
- `mag`: Magnitude of frequency response, size `(ny, nu, length(w))`
328
+
- `phase`: Phase in degrees, size `(ny, nu, length(w))`
329
+
- `w`: Frequency vector used
303
330
304
-
`mag` and `phase` has size `(ny, nu, length(w))`.
305
-
If `unwrap` is true (default), the function `unwrap!` will be applied to the phase angles. This procedure is costly and can be avoided if the unwrapping is not required.
331
+
Note: Phase unwrapping is computationally expensive and can be disabled for better performance. For higher performance, see the function [`bodemag!`](@ref) that computes the magnitude only.
306
332
307
-
For higher performance, see the function [`bodemag!`](@ref) that computes the magnitude only.
333
+
See also [`bodeplot`](@ref), [`bodemag!`](@ref), [`freqresp`](@ref).
Compute the Bode magnitude operating in-place on an instance of [`BodemagWorkspace`](@ref). Note that the returned magnitude array is aliased with `ws.mag`.
334
-
The output array `mag` is ∈ 𝐑(ny, nu, nω).
366
+
Compute the Bode magnitude operating in-place on an instance of [`BodemagWorkspace`](@ref).
367
+
368
+
# Arguments
369
+
- `ws::BodemagWorkspace`: Pre-allocated workspace created with [`BodemagWorkspace`](@ref)
370
+
- `sys::LTISystem`: The system to analyze
371
+
- `w::AbstractVector`: Frequency vector (rad/s)
372
+
373
+
# Returns
374
+
- `mag`: Magnitude of frequency response, size `(ny, nu, length(w))`.
375
+
Note: The returned array is aliased with `ws.mag`.
376
+
377
+
# Performance
378
+
This function provides significant performance benefits for repeated magnitude calculations:
379
+
- Avoids memory allocation by reusing workspace arrays
380
+
- Optimized for systems with many frequency points
381
+
382
+
For thread-safe applications, create one workspace per thread.
383
+
384
+
See also [`BodemagWorkspace`](@ref), [`bode`](@ref), [`freqresp!`](@ref).
0 commit comments