Академический Документы
Профессиональный Документы
Культура Документы
Summary
If an application compiled into a standalone app using the mcc command has protected functions
(pcode) as dependencies, the mcc command will fail to pick up these dependencies. You can use the
function createRequiredFunctionPragmasFile to analyze your application and create a file
having function pragmas to those protected functions. The resulting file when used with the mcc
command will now have the full set of dependencies.
Syntax
createRequiredFunctionPragmasFile(pragmafilename,mfile)
createRequiredFunctionPragmasFile(pragmafilename,{mfile1,...,mfileN})
createRequiredFunctionPragmasFile(pragmafilename,mydir)
createRequiredFunctionPragmasFile(pragmafilename,{mydir1,...,mydirN})
Description
createRequiredFunctionPragmasFile(pragmafilename,mfile) creates a file
containing function pragmas by analyzing a single MATLAB® file.
createRequiredFunctionPragmasFile(pragmafilename,{mfile1,...,mfileN})
creates a file containing function pragmas by analyzing multiple MATLAB® files.
Examples
Create a file containing function pragmas by analyzing a single MATLAB® file
1. Create a function called mymagic.m .
function m = mymagic(in)
m = magic(in);
You will see the function pragmas of the dependent files in the file myPragmaFile.m .
Patents | Trademarks
© 1994-2017 The MathWorks, Inc.
Page 1 of 6
%#function gpuArray
%#function magic
%#function mymagic
3. Convert the function mymagic.m into a protected function file using the MATLAB pcode
function.
>> pcode('mymagic.m')
5. Create another function called myapp.m that calls the function mymagic.p .
function out = myapp(in)
if ischar(in)
in = str2double(in);
end
out = mymagic(in)
6. Create a standalone application of the myapp.m function using the mcc command.
The mcc command will create a standalone app with necessary dependencies due to the
function pragma file.
function m = mymagic(in)
m = magic(in);
function n = mypascal(in)
n = pascal(in);
You will see the function pragmas of the dependent files in the file myPragmaFile.m .
Patents | Trademarks
© 1994-2017 The MathWorks, Inc.
Page 2 of 6
%#function gpuArray
%#function magic
%#function mymagic
%#function mypascal
%#function pascal
4. Convert the functions mymagic.m and mypascal.m into protected function files using the
MATLAB pcode function.
>> pcode('mymagic.m','mypascal.m')
6. Create a function called myapp.m that calls the functions mymagic.p and mypascal.p .
function [out1,out2] = myapp(in)
if ischar(in)
in = str2double(in);
end
out1 = mymagic(in)
out2 = mypascal(in)
7. Create a standalone application of the myapp.m function using the mcc command.
The mcc command will create a standalone app with necessary dependencies due to the
function pragma file.
2. Create a function called mymagic.m and save it in the newly created directory mydir.
function m = mymagic(in)
m = magic(in);
3. Create another function called mypascal.m and save it in the newly created directory mydir.
function n = mypascal(in)
n = pascal(in);
Patents | Trademarks
© 1994-2017 The MathWorks, Inc.
Page 3 of 6
mydir
|-mymagic.m
|-mypascal.m
5. From the parent directory of the mydir folder, use the function
createRequiredFunctionPragmasFile to create a file containing function pragmas of
dependent files.
>> createRequiredFunctionPragmasFile('myPragmaFile.m','mydir')
You will see the function pragmas of the dependent files in the file myPragmaFile.m .
%#function gpuArray
%#function magic
%#function mymagic
%#function mypascal
%#function pascal
>> cd mydir
7. Convert the functions mymagic.m and mypascal.m into protected function files using the
MATLAB pcode function.
>> pcode('mymagic.m','mypascal.m')
>> cd ..
>> addpath('mydir')
11. Create a function called myapp.m that calls the functions mymagic.p and mypascal.p .
function [out1,out2] = myapp(in)
if ischar(in)
in = str2double(in);
end
out1 = mymagic(in)
out2 = mypascal(in)
Patents | Trademarks
© 1994-2017 The MathWorks, Inc.
Page 4 of 6
12. Create a standalone application of the myapp.m function using the mcc command.
The mcc command will create a standalone app with necessary dependencies due to the
function pragma file.
2. Create the same MATLAB functions mymagic.m and mypascal.m mentioned in the second
and third examples and include the files in mydir1 and mydir2 as follows:
mydir1
|- mymagic.m
mydir2
|-mypascal.m
3. From the parent directory of mydir1 and mydir2, use the function
createRequiredFunctionPragmasFile to create a file containing function pragmas of
dependent files.
>> createRequiredFunctionPragmasFile('myPragmaFile.m',{'mydir1',
'mydir2'})
You will see the function pragmas of the dependent files in the file myPragmaFile.m .
%#function gpuArray
%#function magic
%#function mymagic
%#function mypascal
%#function pascal
This list is the same as seen in example two and three.
4. Switch to the directory mydir1 and convert the functions mymagic.m into a protected
function file using the MATLAB pcode function.
>> pcode('mymagic.m')
6. Switch to the directory mydir2 and convert the function mypascal.m into a protected
function file using the MATLAB pcode function.
>> pcode('mypascal.m')
Patents | Trademarks
© 1994-2017 The MathWorks, Inc.
Page 5 of 6
7. Delete the function mypascal.m.
>> cd ..
9. Create a function called myapp.m that calls the functions mymagic.p and mypascal.p .
function [out1,out2] = myapp(in)
if ischar(in)
in = str2double(in);
end
out1 = mymagic(in)
out2 = mypascal(in)
10. Add the folders mydir1 and mydir2 to the MATLAB path.
11. Create a standalone application of the myapp.m function using the mcc command.
The mcc command will create a standalone app with necessary dependencies due to the
function pragma file.
Input Arguments
pragmafilename — File name
Patents | Trademarks
© 1994-2017 The MathWorks, Inc.
Page 6 of 6