MATLAB Compiler | ![]() ![]() |
Setting Indentation Spacing
Use the statement-indent:n
option to set the indentation of all statements to n
, an integer. The default is 4 spaces of indentation. To set the indentation for expressions, use expression-indent:n
. This sets the number of spaces of indentation to n
, an integer, and defaults to two spaces of indentation.
Default Indentation
Not specifying indent formatting options uses the default of four spaces for statements and two spaces for expressions. For example, using
generates the following code segment:
0 1 2 3 4 5 6 7 8 12345678901234567890123456789012345678901234567890123456789012345678901234567890 void mlxGasket(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) { mxArray * mprhs[1]; mxArray * mplhs[1]; int i; if (nlhs > 1) { mlfError( mxCreateString( "Run-time Error: File: gasket Line: 1 Column: " "1 The function \"gasket\" was called with mor" "e than the declared number of outputs (1)."), NULL); } if (nrhs > 1) { mlfError( mxCreateString( "Run-time Error: File: gasket Line: 1 Column: " "1 The function \"gasket\" was called with mor" "e than the declared number of inputs (1)."), NULL); } for (i = 0; i < 1; ++i) { mplhs[i] = NULL; } for (i = 0; i < 1 && i < nrhs; ++i) { mprhs[i] = prhs[i]; } for (; i < 1; ++i) { mprhs[i] = NULL; } mlfEnterNewContext(0, 1, mprhs[0]); mplhs[0] = Mgasket(nlhs, mprhs[0]); mlfRestorePreviousContext(0, 1, mprhs[0]); plhs[0] = mplhs[0]; }
Modified Indentation
This example shows the same segment of code using a statement indentation of two and an expression indentation of one:
generates the following code segment:
0 1 2 3 4 5 6 7 8 12345678901234567890123456789012345678901234567890123456789012345678901234567890 void mlxGasket(int nlhs, mxArray * plhs[], int nrhs, mxArray * prhs[]) { mxArray * mprhs[1]; mxArray * mplhs[1]; int i; if (nlhs > 1) { mlfError( mxCreateString( "Run-time Error: File: gasket Line: 1 Column: 1 The function \"gaske" "t\" was called with more than the declared number of outputs (1)."), NULL); } if (nrhs > 1) { mlfError( mxCreateString( "Run-time Error: File: gasket Line: 1 Column: 1 The function \"gaske" "t\" was called with more than the declared number of inputs (1)."), NULL); } for (i = 0; i < 1; ++i) { mplhs[i] = NULL; } for (i = 0; i < 1 && i < nrhs; ++i) { mprhs[i] = prhs[i]; } for (; i < 1; ++i) { mprhs[i] = NULL; } mlfEnterNewContext(0, 1, mprhs[0]); mplhs[0] = Mgasket(nlhs, mprhs[0]); mlfRestorePreviousContext(0, 1, mprhs[0]); plhs[0] = mplhs[0]; }
![]() | Listing All Formatting Options | Including M-File Information in Compiler Output | ![]() |