function build(verNum,target,dataType,WordLength)
% BUILD function generates code for myfilter_xx.m
%
% Syntax: build xx
% build xx yyy
% build xx yyy dddddd
% build xx yyy dddddd nn
%
% Examples: build 03 lib
% build 03 mex single
% build 03 mex fixed 16
%
% Created by: Rick Rosson, 2008 September 15
%
% Copyright (c) 2008 The MathWorks, Inc. All rights reserved.
%
%
% Variable number of input arguments:
if nargin < 4
WordLength = 12;
end
if nargin < 3
dataType = 'double';
end
if nargin < 2
target = 'mex';
end
% Check to see if verNum is a string:
if ischar(verNum)
verNum = str2double(verNum);
end
if ischar(WordLength)
WordLength = str2double(WordLength);
end
% Length of input vector:
N = 30;
% Example Inputs:
% ExampleInputs = { zeros(N,1,dataType) };
% Source Code File Name:
% fileroot = 'myfilter';
% sourcefile = [ fileroot '_' num2str(verNum,'%02i') ];
% RTW Targets:
% if strcmp(target,'lib')
% target = ['rtw:' target ];
% end
% Release pre-compiled functions:
clear functions;
% Switch Yard:
switch verNum
case 1
switch target
case 'mex'
emlc myfilter_01 ...
-eg { zeros(N,1,dataType) } ...
-report ...
-o myfilter_01_mex ...
-T mex
case 'lib'
emlc myfilter_01 ...
-eg { zeros(N,1,dataType) } ...
-report ...
-c ...
-T rtw:lib
otherwise
error('Target is not valid.');
end
case 2
switch target
case 'mex'
emlc myfilter_02 ...
-eg { zeros(N,1,dataType) } ...
-report ...
-o myfilter_02_mex ...
-T mex
case 'lib'
emlc myfilter_02 ...
-eg { zeros(N,1,dataType) } ...
-report ...
-c ...
-T rtw:lib
otherwise
error('Target is not valid.');
end
case 3
switch dataType
case { 'double' 'single' }
switch target
case 'mex'
emlc myfilter_03 ...
-eg { zeros(N,1,dataType) } ...
-report ...
-o myfilter_03_mex ...
-T mex
movefile('myfilter_03_mex.mexw32', ...
[ 'myfilter_03_' dataType '.mexw32' ]);
case 'lib'
emlc myfilter_03 ...
-eg { zeros(N,1,dataType) } ...
-report ...
-c ...
-T rtw:lib
otherwise
error('Target is not valid.');
end
case 'fixed'
signed = 1;
FracLength = WordLength - signed - 2;
dataType = numerictype(signed,WordLength,FracLength);
switch target
case 'mex'
emlc myfilter_03 ...
-eg { fi(zeros(N,1),dataType) } ...
-report ...
-o myfilter_03_mex ...
-T mex
movefile('myfilter_03_mex.mexw32', ...
[ 'myfilter_03_sfix' ...
num2str(WordLength) '.mexw32' ]);
case 'lib'
emlc myfilter_03 ...
-eg { fi(zeros(N,1),dataType) } ...
-report ...
-c ...
-T rtw:lib
otherwise
error('Target is not valid.');
end
otherwise
error('Data type is not valid.');
end
otherwise
error('Version number is not valid.');
end
end