Right indentifiers makes the code look better. It makes it appear as if it has been “slightly” indented. But there are situations when this does not help make your code look better. Let’s take a look at the following MATLAB code. The code starts out by indenting the current line, then a new line and then another indentation.
The code does look cleaner when first looked at. However, with increasing levels of indentation, the code looks less clean and easier to read. The reader can easily understand that the first four lines of the code are indented one-two spaces. This makes for a much easier to read and helps to move the reader into understanding what the code is doing.
When writing MATLAB code, all you need to do is to use the standard system indentifiers. However, when working on an assignment, MATLAB is always smarter. It knows when you need its own Indentifier settings.
For instance, if you are in a MATLAB window that has a button in the lower left corner that displays the next data point. While you are working on your assignment, the current button is pressed and is now displaying data from the last time you ran the assignment. With this new data in a view, you now see that the indentation on the previous four lines is “too much.”
Now, as you might imagine, this is not good practice because you need to know how much indentation to use. The default settings will be “too much.” You need to change the indentation settings to one-two spaces.
This is where you need to understand that MATLAB does not update the indent settings automatically. This means that you have to be quick and efficient with these changes. You need to enter your change, hit return and save. Then, you will need to click the button to change the indentation again.
If you have a manual system indentifier, you might need to print out a couple of copies so that you have several of them on hand. The instructions for running a manual indentifier should be fairly straight forward. However, if you want to create a manual indentifier on your own, the instructions should be easier to follow.
First, you will need to open the Windows Task Manager and highlight the appropriate tool. Next, open the Windows Command Prompt and type “mscomgtool.exe.” When prompted to select a language, select English.
The command that will bring up your identifier is “mscomgtool indent”. Once you press enter, a dialog box will pop up asking you to specify a name for the new identifier. Enter your own name for the identifier and then press enter.
Press control-C to close the command prompt. Then you can type “set indentformat=” without the quotation marks. This is the new indent format that you will be using on all your MATLAB assignments.
In addition to being able to see the indent formatting on a MATLAB window, you will also be able to see the indent formatting in your MATLAB notebook. This makes it easy to edit and update your indent settings. Also, it will be very easy to maintain your indent settings when you are modifying your code.