143
C H A P T E R 10
Implementation Via Matlab
Coder
is chapter presents the steps one needs to take in order to run a signal processing algorithm
written in MATLAB on the ARM processor of smartphones which were initially reported in [1]
by using Simulink. e steps needed are best conveyed by going through an example. is exam-
ple involves the linear convolution filtering algorithm. Considering that MATLAB program-
ming is widely used in signal processing, the approach presented in this chapter allows running
on smartphones many signal processing algorithms which are already written in MATLAB and
publicly available.
10.1 MATLAB FUNCTION DESIGN
is section provides the guidelines for implementing the linear convolution filtering algorithm
via a MATLAB script. e first step is to open MATLAB and create a new function file in
which to implement the algorithm. e following example code provides an implementation of
a frame-based finite impulse response filter (coefficients omitted). Of particular importance in
this function is the usage of the persistent variable buffer . is variable stores previous samples
of the input signal between calls to the FIR function so that the proper filter output is produced.
e actual filtering result is computed using the built-in MATLAB filter function.
function output = FIR(input)
coefficients = []; %FIR filter coefficients
persistent buffer;
if isempty(buffer)
buffer = zeros(1, size(input, (2) + size(coefficients, 2));
end
buffer = [buffer(:, end-size(coefficients,2)+1 : end) input];
filtered = filter(coefficients, 1, buffer);
output = filtered( : , size(coefficients, (2) + 1 : end);]
..................Content has been hidden....................

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