54 3. FROM MATLAB CODER TO SMARTPHONE
Figure 3.5: Function error check.
Once the MATLAB script is checked and passed, a corresponding C source code can
be generated by pressing the Generate button (see Figure 3.6). Although various configuration
settings are available, the default settings are adequate for our purposes. After this step, a folder
named codegen is created in the directory of the MATLAB files.
3.2.3 SOURCE CODE INTEGRATION
e final step to implement an algorithm written in MATLAB on smartphones is to deploy
the generated C code on a suitable target device. For this step, an application shell is provided
here in which the generated C source code needs to be placed. is shell operates in the same
manner as the test bench script stated earlier; that is the two signals (pulse and exponential) are
generated. Figures 3.7 and 3.8 show how the generated C code is placed or integrated into the
Android shell that is provided. e following steps need to be taken.
1. Navigate to the folder named Lab3_1 (MATLAB function name) in the codegen folder;
codegen/lib/Lab3_1. Copy all the files with .h and .c extensions; see Figure 3.7.
2. Place the copied files inside the jni folder of the shell provided. e jni folder appears at
app/src/main/jni; see Figure 3.8.
3. Before building the project, first press Clean Project, as shown in Figure 3.9.