## Demo Source Codes

### Monte Carlo Method Using Octave GNU Tool

Octave GNU file: MonteCarlo.m
The script generates plots of the probability density functions of the normal and uniform random distributions, as well as simulates a probabilistic Voltage Divider model and calculates a definite integral using the Monte Carlo method
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% MonteCarlo.m */
% Monte Carlo Method */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the Monte Carlo article */
%*********************************************************************/

### Overview of Search with C Source Code

Search.c/h with the functions:

uint16 SequentialSearchMethod(sint16*, uint16); – Sequential Search

uint16 BinarySearchMethod(sint16*, uint16, sint16); – Binary Search

tree_search_results_e TreeSearchMethod(tree_node_data_s*, uint16*, sint16); – Tree Search

void MakeBinaryTree(tree_node_data_s*, uint16*, sint16*, uint16); – Make the Binary Tree

void HashTableInit(list_node_data_s**); – Hash Table Initialization

list_search_results_e HashTableSearchMethod(list_node_data_s**, list_node_data_s*, uint16*, sint16); – Hash Table Method

### Bose–Chaudhuri–Hocquenghem (BCH) code: (15, 5, 7) and C Implementation Using the Octave GNU Tool

The C Code:
BCH_Code.c/h

Octave GNU file: BCH_Code.m
The script generates and tests the BCH Code: (15,5,7)
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% BCH_Code.m */
% BCH Code (15,5,7) */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the BCH Code article */
%*********************************************************************/

### Hadamard Codes and C Implementation Using the Octave GNU Tool

The C Code:

The script generates and tests Hadamard Code: (32,6,16) и R(1,5)
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the Hadamard Codes article */
%*********************************************************************/

### Hamming Codes and C Implementation Using the Octave GNU Tool

The C Code:
HammingCode.c/h

Octave GNU file: HammingCode.m
The script generates and tests standard/systematic Hamming Codes: (7,4,3), (15,11,3), extended Hamming Codes (8,4,4), (16,11,4), as well as the classic Hamming Code: (15,11,3), classic extended Hamming Code (16,11,4)
%************************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% HammingCode.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the Hamming Codes article */
%************************************************************************/

### Digital Integrators with an Examples. C Code and Octave Script

The C Code:
DigitalIntegrators.c/h

Octave GNU file: DigitalIntegrators.m
The .m script generates the digital integrator solutions and plots
%************************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% DigitalIntegrators.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: */
% Digital Integrators */
%************************************************************************/

### The Numerical Solution of Partial Differential Equations with an Example. C Code and Octave Script

The C Code:
NumericalPartialDifferentialEquation.c/h

Octave GNU file: NumericalPartialDifferentialEquation.m
The .m script generates the analytical and numerical solutions of the wave partial differential equation and result plots.
%************************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% NumericalPartialDifferentialEquation.m */
% u_tt(x,t) = a_speed^2*u_xx(x,t) */
% u(0,t) = 0 – boundary */
% u(L,t) = 0 – boundary */
% u(x,0) = 0 – initial */
% u_t(x,0) = (a_speed*pi/L)*sin(pi*x/L) – initial */
% u_tt(x,0) = 0 – initial */
% u_pattern = sin(pi*x/L)*sin(a_speed*pi*t/L) */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: */
% Numerical Solution of Partial Differential Equations */
%************************************************************************/

### The Runge-Kutta and Hamming Methods for Numerical Solution of Ordinary Differential Equations with an Example. C Code and Octave Script

The C Code:
NumericalDifferentialEquation.c/h

Octave GNU file: NumericalDifferentialEquation.m
The .m script is supported the differential equation solution with the Runge-Kutta, Hamming and Model methods, generates the step signal and plots.
%************************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% NumericalDifferentialEquation.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: */
% Numerical Solution of Differential Equations */
%************************************************************************/

### Modal Synthesis Method for Control Systems with an Example. C Code and Octave Script

The C Code:
ModalControl.c/h

Octave GNU file: ModalControl.m
The file is supported all plots of the article, generates the tests for the C code and calculates the Modal Control System.
%************************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% ModalControl.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: */
% Modal Synthesis Method for Control Systems */
%************************************************************************/

### Control of Non Linear Object Using the Vostrikov’s Localization Method. C Code and Octave Script

The C Code:
LocalizationForNonLinearObject.c/h

Octave GNU file: LocalizationForNonLinearObject.m
The file is supported all plots of the article, generates the tests for the C code and calculates the Localization Control System.
%************************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% LocalizationForNonLinearObject.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: */
% Localization Method for Non Linear Control Systems */
%************************************************************************/

### Typical Open Loop Bode Diagram for Control Systems. C Code and Octave Script

The C Code:
BodeDiagramType2.c/h

Octave GNU file: OpenLoopMagnitudePhaseRespTypes.m
The file is supported all plots of the article, generates the tests for the C code and calculates the Localization Control System.
%************************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% LocalizationForNonLinearObject.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: */
% Localization Method for Non Linear Control Systems */
%************************************************************************/

### Control System Using the Localization Method from A. S. Vostrikov. C Code and Octave Script

The C Code:
LocalizationControlSystem.c/h

Octave GNU file: LocalizationControlSystem.m
The file is supported all plots of the article, generates the tests for the C code and calculates the Localization Control System.
%************************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% LocalizationControlSystem.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: */
% Localization Method for Linear Control Systems */
%************************************************************************/

### Digital Derivative Filter Using Integrators. C Code and Octave Script

The C Code:
DigitalDerivativeFilter.c/h

Octave GNU file: DerivativeFilter.m
The file is supported all plots of the article, generates the tests for the C code and calculates the Derivative Filter.
%************************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% DerivativeFilter.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: */
% Digital Derivative Filter Using Integrators. C Code and Octave Script */
%************************************************************************/

### Generalized Inverse Matrix on the Example of Converting a Three-Phase Voltage (Ua, Ub, Uc) into a Two-Phase one (Uα, Uβ) in an Electric Motor

Octave GNU file: MatrixGenInverseSupport.m
The Octave script supports the example calculation.
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% MatrixFunctionsSupport.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the Generalized Inverse Matrix article */
%*********************************************************************/

### Matrix Functions for Digital Signal Processing. C Code and Octave Script

The C Code:
MatrixFunctions.c/h

Octave GNU file: MatrixFunctionsSupport.m
The file is supported all plots of the article, generates the tests for the C code and calculates the Matrix Functions.
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% MatrixFunctionsSupport.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the Matrix Functions article */
%*********************************************************************/

### Kalman Filter with Example. C Code and Octave Script

The C Code:
KalmanFilterExample.c/h

Octave GNU file: KalmanFilterExampleSupport.m
The file is supported all plots of the article, generates the test signal file / array for the C code and calculates the Kalman filter.
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% KalmanFilterExampleSupport.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the Kalman Filter with Example article */
%*********************************************************************/

### Simple Scalar Kalman Filter. C Implementation Using the Octave GNU Tool

The C Code:
SimpleKalmanFilter.c/h

Octave GNU file: SimpleKalmanFilterSupport.m
The file is supported all plots of the article, generates the test signal file / array for the C code and calculates the Scalar Kalman filter.
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% SimpleKalmanFilterSupport.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the Simple Scalar Kalman Filter article */
%*********************************************************************/

### Bluestein’s Algorithm or Fourier Transform as Linear Chirp FIR Filter. C Implementation Using the Octave GNU Tool

The C Code:
Bluestein_float.c/h

Octave GNU file: Bluestein_Support.m
The file is supported analysis, tests, generation for the C code.
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% Bluestein_Support.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the Bluestein’s Algorithm article */
%*********************************************************************/

### Cyclic Redundancy Check (CRC): bitwise, lookup table, fast crc without lookup table, reversing crc. C Implementation Using the Octave GNU Tool

The C Code:
crc_x16_x2_x_1.c/h
crc_x16_x12_x5_1.c/h
crc32_0x04C11DB7.c/h
crc_x64_x4_x3_x_1.c/h
reverse_crc_x16_x2_x_1.c/h

Octave GNU file: CRC_support.m
The file is supported generation lookup tables for the C code.
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% CRC_support.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: Cyclic Redundancy Check */
%*********************************************************************/

### Functions Implementation: Square Root, Logarithm, Sine, Cosine, Arctangent. C Code and Octave Script

The C Code:
square_root.c/h
logarithm.c/h
sine.c/h
atan.c/h

Octave GNU file: FunctionsRealization.m
The file is supported analysis, plots, generation for the C code and test.
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% FunctionsRealization.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: Functions Implementation */
%*********************************************************************/

### Simple Embedded Operating System and C Implementation

The C Code: SimpleOS.c/h

### “Non-Causal“ Digital Chebyshev Filter with Linear Phase Response. C Implementation and Octave Script

The C Code: non_causal_filter_integer.c/h and non_causal_filter_float.c/h
Functions:
iir_non_causal_init( )
iir__non_causal_filter( )

Octave GNU file: DigitalChebyshevFilter.m
The file is supported plots, generation for the C code and test.
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% DigitalChebyshevFilter.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: */
% Digital Chebyshev Filter with Linear Phase Response */
%*********************************************************************/

### Goertzel Algorithm and C Implementation Using the Octave GNU Tool

The C Code: GoertzelFilter.c/h
Functions:
int_goertzel_algorithm( )
flt_goertzel_algorithm( )
and so on

Octave GNU file: Goertzel_Filter.m
The file is supported plots, generation for the C code and test.
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% Goertzel_Filter.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: Goertzel filter */
%*********************************************************************/

### Fast Fourier Transform (FFT) and C Implementation Using the Octave GNU Tool

The C Code: fft_float.c/h, fft_integer.c/h
Functions:
fft_decimation_in_time( )
fft_decimation_in_frequency( )
and so on

Octave GNU file: FFT_Support.m
The file is supported arrays generation for the C code and test.
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% FFT_Support.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the FFT article */
%*********************************************************************/

### Digital Slew Rate Limiter Filter and C Implementation

The C Code: SlewRateLimiterFilter.c/h

SRLF Functions:

void srl_filter_init(sint16 init_value);
where init_value – start output y(0) initialization

sint16 srl_filter(sint16 x_input);
where x_input – filter x(n) input
return – filter y(n) output

Slow SRLF Functions. Variant 1:

void slow_v1_srl_filter_init(sint16 init_value);
where init_value – start output y(0) initialization

sint16 slow_v1_srl_filter(sint16 x_input);
where x_input – filter x(n) input
return – filter y(n) output

Slow SRLF Functions. Variant 2:

void slow_v2_srl_filter_init(sint16 init_value);
where init_value – start output y(0) initialization

sint16 slow_v2_srl_filter(sint16 x_input);
where x_input – filter x(n) input
return – filter y(n) output

### Matched Filter Using Octave GNU Tool

Octave GNU file matched_filter.m
You can see in the file all calculations and all graphics for the article.

%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% Matched_Filter.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: Matched filters */
%*********************************************************************/

### Median Filter and C Implementation

C-source code median_filter.c/h

Functions:
sint16 ClassicMedianFilter(sint16* ptrArray, uint16 arraySize); – classic median filter
sint16 AdvanceMedianFilter(sint16* ptrArray, uint16 arraySize); – modification of the median filter
where
ptrArray – pointer on the input data
arraySize – input data length
return value is filter output

### IIR Filter and C Implementation Using Octave GNU Tool

iir_filter_integer.c/h – the IIR filter with the fixed point arithmetic
iir_filter_float.c/h – the IIR filter with the float arithmetic
Functions:
– Form I
void iir_form_I_initialization(void); – clear the filter history (working arrays)
sint16 iir_form_I(sint16 x_input); – calculate the IIR filter: x_input – input, return value is filter output

– Form II
void iir_form_II_initialization(void); – clear the filter history (working arrays)
sint16 iir_form_II(sint16 x_input); – calculate the IIR filter: x_input – input, return value is filter output

– Transposed Form II
void iir_transposed_form_II_initialization(void); – clear the filter history (working arrays)
sint16 iir_transposed_form_II(sint16 x_input); – calculate the IIR filter: x_input – input, return value is filter output

Octave GNU file IIR_Filter.m  – analysis and plot
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% IIR_Filter.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: IIR Filter */
%*********************************************************************/

### FIR Filter Implementation Using Octave GNU Tool and C Language

fir_filter.c/h with the functions:

void fir_filter_initialization(void) – initialize / clear the filter history (x(n-1),…x(n-N+1))

sint16 fir_filter_float(sint16 x_input) – calculate the output signal y(n) using the input signal x(n)=x_input. The function is used the float FIR coefficients

sint16 fir_filter_integer(sint16 x_input) – calculate the output signal y(n) using the input signal x(n)=x_input. The function is used the integer FIR coefficients

The Octave GNU file:  Fir_Filter.m  – analysis and plot
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% Version 1.0 */
% FIR_Filter.m */
% Octave Script */
% High-level interactive language for numerical computations */
% Support the article: FIR filters */
%*********************************************************************/

### Overview of Sorts with C Source Code

sorts.c/h with the functions:
void BubbleSortMethod(sint16*, uint16); – Bubble Sort
void InsertionSortMethod(sint16*, uint16); – Insertion Sort
void ShellSortMethod(sint16*, uint16, uint16); – Shell Sort
void QuickSortMethod(sint16*, uint16); – Quick Sort
void HeapSortMethod(sint16*, uint16); – Heap Sort

### Bessel Filter in Digital Form?

The Octave GNU file: DigitalBesselFilter.m has all calculations for the article. You can test self the different variants.
%*********************************************************************/
% Freeware Demo SW from the www.dsp-weimich.com */
% DigitalBesselFilter.m */
% Octave Script */
% High-level interactive language for numerical computations*/
% Support the article: Bessel Filter in Digatal Form? */
%*********************************************************************/

### Simple Low Pass IIR Filter Implementation Using the C Language

IIRfirstOrderFixedPoint.c/h – implementation with single multiplication and fixed point arithmetic
IIRfirstOrderFloat.c/h – implementation with single multiplication and float point arithmetic
IIRfirstOrderShift.c/h – implementation with shift operation instead of multiplication and fixed point arithmetic