Implementing a MATLAB digital filter or controllers in C++

Controllers and filters are often a good way to stabilise a system, condition a signal or make a system follow a reference. The usual approach is to model the system or signal in an application like MATLAB and then design a filter or controller. Either by applying design rules, some sort of optimisation algorithm or tuning parameters experimentally. When the design is finished the controller or filter is not ready for use yet. It is still necessary to realise it in practice. This is often done digitally on a micro controller or real-time computer. This article will describe a effective, open and fast approach to realising a filter or controller in C++.

Step responses of Butterworth Low-pass Filters
Step responses of Butterworth Low-pass digital filters with different cut-off frequencies

Continue reading Implementing a MATLAB digital filter or controllers in C++

Random Midpoint Displacement Fractal (RMDF)

The Random Midpoint Displacement Fractal (RMDF) is a fractal this is often used for generating height-maps, landscapes, rough surfaces and more. Its implementation is simple but the results are interesting, especially when a nice color-map is applied to the matrix and it is shown as a 3D-surface.

Example of a Random Midpoint Displacement Fractal

Continue reading Random Midpoint Displacement Fractal (RMDF)

Matlab2Tikz: Perfect MATLAB Figures in LaTeX

MATLAB exported TikZ picture with custom stylingPapers and reports can’t do without both but integrating MATLAB figures in LaTeX is not so obvious. Different methods for exporting and including graphics exist but have various downsides like inconsistent scaling, wrong fonts and strange spacing. The best method I have come across so far is using matlab2tikz. It is a MATLAB script that is able to extract all relevant details out of a figure and convert it to PGFPlots (a LaTeX package).

Continue reading Matlab2Tikz: Perfect MATLAB Figures in LaTeX