How do I compile the REMEZ function from the Signal ProcessingToolbox using the MATLAB Compiler?

5 views (last 30 days)
How do I compile the REMEZ function from the Signal ProcessingToolbox using the MATLAB Compiler?
When I compile the code below:
function foo
f = [0 0.3 0.4 0.6 0.7 1]; a = [0 0 1 1 0 0];
b = remez(17,f,a);
[h,w] = freqz(b,1,512);
plot(f,a,w/pi,abs(h))
legend('Ideal','remez Design')
I received two RUNTIME errors:
Reference to unknown function 'remezfrf' from FEVAL in stand-alone mode.
Unable to find remezmex executable
How do I compile the above code?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
There are issues with Signal Processing Toolbox compilation because some of the functions in the toolbox use objects and other restrictions of the MATLAB Compiler, listed in the solution attached at the bottom of this page.
We have not tried compiling REMEZ using the add-in, however, we have managed to create a standalone from MATLAB environment, and we hope this could help you for the time being.
function foo
f = [0 0.3 0.4 0.6 0.7 1]; a = [0 0 1 1 0 0];
b = remez(17,f,a);
[h,w] = freqz(b,1,512);
plot(f,a,w/pi,abs(h))
legend('Ideal','remez Design')
The code above comes from the documentation of REMEZ (type "doc remez" to see it).
REMEZ has two issues:
Issue 1. It uses FEVAL to evaluate the function REMEZFRF, without a function handle. During compile time it will have a runtime error because REMEZFRF can not be found.
Issue 2. It uses the function EXIST, to check for existence of REMEZMEX.dll, The function EXIST falls under the limitation of MATLAB Compiler.
Here is what you should do to resolve these two issues so that the above code (FOO.m) will compile:
Issue 1. Copy REMEZFRF.m and REMEZMEX.dll into the same directory as FOO.m. The two files are in:
$MATLAB/toolbox/signal/signal/private
where $MATLAB is the directory where MATLAB is installed.
Having these functions in the same directory as FOO.m will allow them to be found during compilation.
Issue 2. Type "edit remez", and change line 281 in REMEZ.m
from
if (exist('remezmex') == 3)
to
if (exist('remezmex') == 0)
This simply means "don't bother checking. We know REMEZMEX.dll exists". By eliminating this check, we will avoid the built-in use of the EXIST function, allowing REMEZ to compile.
Once these changes are made, you will need to update your toolbox cache. This can be accomplished by typing the following at the MATLAB command prompt:
rehash toolboxcache
You should now be able to compile the REMEZ function using the following command:
mcc -B sgl foo.m remezfrf.m
The resulting executable can be run by typing
! foo

More Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!