All notable changes to CppPlot library will be documented in this file.
-
Matrixclass for linear algebra operations- Addition, subtraction, multiplication
- Transpose, determinant, inverse
- Eye, zeros factory methods
-
StateSpaceclass for state-space representation (ẋ = Ax + Bu, y = Cx + Du)- Poles calculation via characteristic polynomial
- Stability check
- Controllability matrix and test
- Observability matrix and test
-
Conversion Functions:
tf2ss(G)- Transfer function to controllable canonical formss2tf(sys)- State-space to transfer function (SISO)
-
Simulation:
lsim(sys, u, t, x0)- Arbitrary input simulationss_step(sys)- Step response of state-space systeminitial(sys, x0)- Initial condition response
-
Pole Placement:
acker(A, B, poles)- Ackermann's formulaplace(A, B, real_poles)- Simplified real pole placementplace_complex(A, B, poles)- Complex conjugate poles
-
LQR Controller:
care(A, B, Q, R)- Continuous algebraic Riccati equation solverlqr(A, B, Q, R)- Linear Quadratic Regulator designlqr_simple(A, B, q_diag, r)- Simplified diagonal weights interface
-
Observer Design:
observer_gain(A, C, poles)- Luenberger observer via dualityplace_observer(A, C, poles)- Simplified observer placement
-
Sensitivity Analysis:
SensitivityFunctionsstruct (S, T, CS, PS)sensitivity(G, K)- Calculate all sensitivity functionssensitivity_plot(G, K)- Plot sensitivity Bode diagram
-
PID Tuning:
ziegler_nichols(Ku, Tu, type)- Z-N tuning (P, PI, PID, no-overshoot)cohen_coon(K, T, L, type)- Cohen-Coon for FOPDT plantspid_tf(gains)- Create PID transfer function from gains
-
Compensator Design:
design_lead(phi_max, wc)- Lead compensator for phase margindesign_lag(gain_increase, wc)- Lag compensator for DC gain
-
Standard Control Loops:
closed_loop(G, C, H)- Standard feedback looppid_loop(G, Kp, Ki, Kd)- PID control looptwo_dof_loop(G, Cr, Cy)- Two degree-of-freedom structure
-
Advanced Structures:
cascade_control(G1, G2, C1, C2)- Nested/cascade controlfeedforward_loop(G, C, Cff)- Feedforward compensationnfeedback(G, H)/pfeedback(G, H)- Explicit feedback sign
-
Disturbance Analysis:
disturbance_to_output(G, C)- d→y transfer functionnoise_to_output(G, C)- n→y transfer function
-
IMC:
imc_to_classical(G, Cimc)- Convert IMC to classical formimc_first_order(K, tau, lambda)- IMC design for first-order
-
Loop Shaping:
gain_for_crossover(G, wc)- Find gain for desired crossoverrequired_phase_lead(G, wc, PM)- Calculate required phase boost
- Added
control_design_demo.cppwith comprehensive examples:- State-space modeling of DC motor
- TF ↔ SS conversions
- Pole placement design
- LQR controller design
- Observer design
- PID tuning methods
- Lead compensator design
- Sensitivity function analysis
nichols(G, options)- Plot Nichols chart for single systemnichols(systems, labels, options)- Compare multiple systemsnichols_m_circle(M_dB)- Generate M-circle (constant CL magnitude)nichols_n_circle(N_deg)- Generate N-circle (constant CL phase)NicholsOptionsstruct with show_m_circles, show_n_circles, show_margins
-
DiscreteTransferFunctionclass for z-domain transfer functions- Sample time handling (Ts)
- Poles/zeros in z-plane
- Stability check (unit circle criterion)
- DC gain, Nyquist frequency
-
Discretization Methods:
c2d_tustin(Gc, Ts)- Bilinear (Tustin) transformc2d_zoh(Gc, Ts)- Zero-Order Hold approximation
-
Discrete Factory Functions:
dtf_integrator(Ts)- Forward Euler integratordtf_integrator_tustin(Ts)- Tustin integratordtf_lowpass(tau, Ts)- First-order lowpass filter
-
Discrete Plotting:
dbode(H)- Discrete Bode diagram (0 to Nyquist)dzpmap(H)- Pole-zero map in z-plane with unit circledstep(H, n)- Discrete step response (stem plot)dsysinfo(H)- Print discrete system information
- Added
control_advanced_demo.cppwith 8 comprehensive examples:- Nichols chart single/comparison
- Discrete Bode, pole-zero, step response
- Continuous to discrete conversion comparison
- Second-order discretization
- Digital lowpass filter design
Complete control systems analysis and plotting library following Python Control / MATLAB standards.
New Files:
control.hpp- Main control module headerpolynomial.hpp- Polynomial arithmetic classtransfer_function.hpp- Transfer function class with full arithmeticanalysis.hpp- Margin, stepinfo, bandwidth, stability analysisbode.hpp- Automatic Bode plot generationnyquist.hpp- Nyquist diagram with critical pointpzmap.hpp- Pole-zero map with damping linesroot_locus.hpp- Root locus plottingtime_response.hpp- Step, impulse response
Transfer Function Features:
- Create from coefficients:
TransferFunction G({1}, {1, 2, 1}); - Create from zeros/poles/gain:
zpk({-1}, {-2, -3}, 5.0) - Factory functions:
tf_second_order(),tf_first_order(),tf_integrator() - Arithmetic: Series (
*), Parallel (+), Feedback (feedback()) - Properties:
poles(),zeros(),dcgain(),isStable()
Analysis Functions:
margin(G)- Gain and phase marginsstepinfo(G)- Rise time, settling time, overshootbandwidth(G)- -3dB bandwidthdamp(G)- Damping ratio and natural frequency of poles
One-liner Plotting (Python Control style):
bode(G); // Automatic Bode plot
nyquist(G); // Nyquist diagram
pzmap(G); // Pole-zero map
rlocus(G); // Root locus
step(G); // Step response
impulse(G); // Impulse responseStandard Test Systems:
systems::first_order(K, tau);
systems::second_order(wn, zeta, K);
systems::integrator(K);
systems::type1(K, a);
systems::pid(Kp, Ki, Kd);
systems::lead(z, p, K);
systems::lag(z, p, K);- Added
control_module_demo.cppwith comprehensive examples - Generated SVG outputs: step, bode, nyquist, pzmap, rlocus
LaTeXRendererclass incore/latex.hppfor converting LaTeX to Unicode- Support for Greek letters:
\alpha,\beta,\gamma,\Delta,\Theta, etc. - Support for superscripts:
x^2,x^{10},e^{i\pi}→ x², x¹⁰, eⁱπ - Support for subscripts:
x_1,x_{12}→ x₁, x₁₂ - Support for math operators:
\sum,\int,\prod,\partial,\nabla,\infty - Support for relations:
\leq,\geq,\neq,\approx,\equiv - Support for arrows:
\to,\leftarrow,\Rightarrow,\leftrightarrow - Support for logic symbols:
\forall,\exists,\wedge,\vee - Support for fractions:
\frac{a}{b}→ (a/b) - Support for square root:
\sqrt{x}→ √(x)
figtext(x, y, text, opts)- Add text at figure coordinates (0-1 normalized)- x=0 is left edge, x=1 is right edge
- y=0 is bottom, y=1 is top
- Perfect for adding formulas, titles, or annotations anywhere on the figure
latex(x, y, expr, opts)- Explicitly render LaTeX expression
- Auto-detection of LaTeX in text (backslash commands,
^,_,$) usetexoption to force LaTeX rendering- Math font family default for LaTeX text (STIX Two Math, Cambria Math)
TextAnnotationstruct now includesfigureCoords,useLaTeX,useMathMLflagstext()function now automatically parses LaTeX commandsdrawAnnotations()now supports figure coordinates and LaTeX rendering
- Added
latex_demo.cppwith 8 comprehensive examples:- Greek letters in labels
- Superscripts and subscripts
- Gaussian distribution with formula
- Physics equations (projectile motion)
- Calculus notation (derivatives, integrals)
- Math symbols reference chart
- Euler's formula visualization
- Statistical formulas
errorbar(x, y, yerr, opts)- Plot with vertical error barserrorbar(x, y, xerr, yerr, opts)- Plot with both X and Y error bars- Supports
capsizeoption for error bar cap width - Supports standard styling options (color, linewidth, label)
- Supports
fill_between(x, y1, y2, opts)- Fill area between two curvesfill_between(x, y, baseline, opts)- Fill area to a constant baseline- Supports
alphafor transparency - Supports
colorandlabeloptions - Useful for confidence intervals, stacked areas
- Supports
text(x, y, "label", opts)- Add text annotation at data coordinatesannotate("text", x, y, textX, textY, opts)- Add annotation with arrow- Supports
fontsize,fontweight,fontstyle - Supports
color(ortextcolor) - Supports alignment:
ha(left/center/right),va(top/center/bottom)
- Supports
set_xscale("log")/xscale("log")- Set X axis to logarithmic scaleset_yscale("log")/yscale("log")- Set Y axis to logarithmic scale- Scale can be "linear" (default) or "log"
axhline(y, opts)- Add horizontal line across the plotaxvline(x, opts)- Add vertical line across the plot- Supports
color,linewidth,linestyle - Useful for marking thresholds, means, or key values
- Supports
- Updated
Axesclass with new private draw methods - Added
niceLogTicks()utility function for log scale tick generation
- Updated README with new feature examples
- Updated AUDIT_REPORT.md with implementation status
- Added new demo files:
advanced_demo.cpp- Comprehensive demo of all new featureslog_scale_demo.cpp- Log scale specific examples
- Line plots with format strings (matplotlib style)
- Scatter plots with size and color mapping
- Bar charts (vertical)
- Histograms with bin control
- Subplot system with flexible layouts
- GridSpec for advanced layouts
- SVG backend for vector output
- Rich styling system (colors, line styles, markers)
- Font customization (size, weight, style, family)
- Legend support
- Grid lines
- Axis labels and titles
- Header-only library
- C++14 compatible
- Cross-platform (Windows, Linux, macOS)
- Matplotlib-like API
- Julia Plots-inspired layout system