52 3. FROM MATLAB CODER TO SMARTPHONE
is function has three inputs, a , b , and Delta . e parameter a controls the am-
plitude of the pulse signal and the parameter b controls the decreasing rate of the exponential
function. e parameter Delta controls the time resolution or spacing between time samples.
x1 and x2 denote the pulse and the exponential signals, respectively.
3.2.1 TEST BENCH
A useful next step is functional verification. is step helps verify the response on a smartphone
target. e following script shows how such a verification is achieved for the above algorithm:
clear all;
clc;
Delta=0.001; %Time interval between samples
a=2; %Amplitude of the pulse signal
b=3; %Decay rate of the exponential function
[x1,x2]=Lab3_1(a,b,Delta); %Calling the function
which performs operations
is script generates the two signals corresponding to a=2 and b = 3 for Delta = 0.001 .
3.2.2 C CODE GENERATION
After defining the MATLAB function and the test bench script code, an equivalent C code
needs to be generated via the MATLAB Coder. e MATLAB Coder (or simply Coder) can
be found in the toolbar under APPS. e following screenshot shows the process of generating
an equivalent C source code from a MATLAB code. Before performing this step, it is important
to make sure that the directory of the MATLAB files appears as the MATLAB directory. Run
the test bench code and then take the steps stated below.
Figure 3.3 shows the initial screen displayed for the Coder. Start by selecting the func-
tion to be converted and change the Numeric Conversion option to single precision floating-point
arithmetic. Note that the single precision floating-point arithmetic is available in MATLAB 2015b
and later versions and care must be taken in using the right version of MATLAB.
After the function is selected, the input types need to be specified (see Figure 3.4). is can
be done either manually or by using the above test bench script to automatically determine the
data types. Select the test bench script and choose the Autodefine Input Types option to complete
this step.
After the input types are set, the Coder then checks to ensure that it is able to generate
a C code from the provided MATLAB script. Figure 3.5 shows the outcome with no detected
errors. Although many of the built-in MATLAB functions work with the MATLAB Coder,
not all the functions are supported. Unsupported functions need to be written from scratch by
the programmer.
3.2. GENERATING SIGNALS VIA MATLAB ON SMARTPHONES 53
Figure 3.3: MATLAB Coder function selection.
Figure 3.4: Input types.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.172.115