User`s guide
Magic Square Example
Magic Square Example
This example shows you how to:
• Access the examples provided with MATLAB Compiler.
• UseMATLABCompilertocreateandpackageasimplestandalone
application.
About the Examples The exam ples for MATLAB Compiler are in
matlabroot\extern\examples\compiler.Formatlabroot,substitute
the MATLAB root directory on y our system. Type
matlabroot to see this
directory name.
The Magic Square example shows you how to create and package a simple
application that compiles an M-file,
magicsquare.m.
magicsquare.m
function m = magicsquare(n)
%MAGICSQUARE generates a magic square matrix of the size specified
% by the input parameter n.
% Copyright 2003-2007 The MathWorks, Inc.
if ischar(n)
n=str2num(n);
end
m = magic(n)
1 Create a subdirectory in your work directory and name it MagicExamp le.
This procedure assumes that your work directory is
D:\Work.
2 Copy the following file to Magic Example:
matlabroot\extern\examples\compiler\magicsquare.m
3 At the MATLAB comm and prompt, change directory to
D:\Work\MagicExample.
1-7