MATLAB-based algorithm integration
We can benefit from the rapid prototype approach in C code as well. After we make the serial driver ready, it can be easily integrated with the algorithm written in MATLAB. Recall what we have done in the previous chapter: the complex algorithm can be quickly implemented in high-level MATLAB m-script and then compiled into a static C library. In the main()
function (refer to main_avg.c
file in the source code of Chapter 5), we can call both the device driver and the algorithm function. In this section, we will provide a simple example, which will utilize the MATLAB algorithm that we developed in the previous chapter.
The algorithm is based on the fact that there could be a "false alarm". A false alarm means the device gives out the positive signal, but there is no such motion in the real world. The false alarm is due to the noise inside the device and the environment, especially when the device is switched into high-sensitivity mode. Therefore, we usually...