IN THIS CHAPTER
Obtaining and installing your copy of MATLAB
Starting MATLAB and working with the interface
Before you can use MATLAB to do anything productive, you need a copy of it installed on your system. Fortunately, you can obtain a free trial version that lasts 30 days from https://www.mathworks.com/campaigns/products/trials/matlab.html. If you’re diligent, you can easily complete this book in that time and know for certain whether you want to continue using MATLAB as a productivity aid. The point is that you need a good installation, and this book helps you obtain that goal.
After you have MATLAB installed, it’s important to introduce yourself to the interface. This chapter provides you with an overview of the interface, not a detailed look at every feature. However, overviews are really important because working with lower-level interface elements is hard if you don’t have the big picture. You may actually want to mark this chapter in some way so that you can refer back to the interface information.
A problem that anyone can encounter is getting a bad product installation or simply not having the right software installed. When you can’t use your software properly, the entire application experience is less than it should be. The following sections guide you through the MATLAB installation so that you can have a great experience using it.
Discovering which platforms MATLAB supports
Before you go any further, you need to verify that your system will actually run MATLAB. At a minimum, you need 3.5GB of free hard drive space (5GB to 8GB for a typical installation) and 4GB of RAM (8GB recommended) to use MATLAB effectively. Your system should also have a newer processor with at least four cores. If you install the Parallel Computing Toolbox, you can also make use of GPU processing functionality for display adapters listed at https://www.mathworks.com/help/parallel-computing/gpu-support-by-release.html. (It can run on systems with fewer resources, but you won’t be happy with the performance.) You also need to know which platforms MATLAB supports. You can use it on these systems:
· Windows 10 (version 1803 or higher)
· Windows 7 Service Pack 1
· Windows Server 2019
· Windows Server 2016
· Mac OS X
· macOS Big Sur (11)
· macOS Catalina (10.15)
· macOS Mojave (10.14)
· Ubuntu 20.04 LTS
· Ubuntu 18.04 LTS
· Ubuntu 16.04 LTS
· Debian 10
· Debian 9
· Red Hat Enterprise Linux 8
· Red Hat Enterprise Linux 7 (minimum 7.5)
· SUSE Linux Enterprise Desktop 12 (minimum SP2)
· SUSE Linux Enterprise Desktop 15
· SUSE Linux Enterprise Server 12 (minimum SP2)
· SUSE Linux Enterprise Server 15
Getting your copy of MATLAB
Before you can work with MATLAB, you need a copy installed on your system. Fortunately, you have a number of methods at your disposal. Here are the three most common ways of getting MATLAB:
· Get the trial version from https://www.mathworks.com/campaigns/products/trials/matlab.html.
· Obtain a student version of the product from https://www.mathworks.com/academia/student_version/.
· Buy a copy from http://www.mathworks.com/pricing-licensing/index.html.
You need to download the copy of MATLAB or the MATLAB installer onto your system after you fill out the required information to get it. In most cases, you install the download on the same system, but there are also methods for downloading and then installing on another system.
Performing the installation
The method you use to install MATLAB depends on the version you obtain and the technique you need to install it. For example, there is one method for installing MATLAB on a separate machine using the file installation key, and there’s an entirely different method when you want to download the installer and use an Internet connection. Administrators and users also have different installation procedures, especially when working with multiple machine installations. Use the table at https://www.mathworks.com/help/install/install-products.html to determine which installation procedure to use.
MathWorks provides you with substantial help in performing the installation. Before you contact anyone, be sure to look through the materials on the main installation page at https://www.mathworks.com/help/install/index.html. Take the time to review the material that MathWorks provides before you push the panic button. Doing so will save time and effort.
Activating the product
After you complete the MATLAB installation, you must activate the product. Activation is a verification process. It simply means that MathWorks verifies that you have a valid copy of MATLAB on your system. With a valid copy, you obtain support such as updates to your copy of MATLAB as needed.
MATLAB automatically asks you about activation after the installation process is complete. You don’t need to do anything special. However, in some cases, you might need to perform the task in some other way. The MATLAB Answers page at https://www.mathworks.com/matlabcentral/answers/99457-how-do-i-activate-matlab-or-other-mathworks-products gives you additional details.
USING MATLAB ONLINE
Even though this chapter focuses on using your copy of MATLAB at the desktop, you can also use MATLAB Online if you have the correct license (see https://www.mathworks.com/products/matlab-online.html#license-types for details). MATLAB Online works much like MATLAB desktop, except that you see the interface through a browser, which means that you could potentially use MATLAB on your tablet. To use MATLAB Online, make sure you meet the requirements specified at https://www.mathworks.com/support/requirements/browser-requirements.html. MATLAB Online also comes with some limitations, as described at https://www.mathworks.com/products/matlab-online/limitations.html. In all other respects, if you can perform a task using your desktop copy of MATLAB, you can also perform it using MATLAB Online. Given that the interfaces are essentially the same, this book doesn’t mention MATLAB Online again unless there is some special functionality or issue you need to know about. Whether you should use MATLAB Online or not depends on a great many factors, such as your network bandwidth and the capabilities of your machine. To see whether using MATLAB Online will work for you, try running a few examples both locally and by using MATLAB Online to determine the performance and usage advantages of each.
Meeting the MATLAB Interface
Most applications have similar interface functionality. For example, if you click a button, you expect something to happen. The button usually contains text that tells you what will happen when you click it, such as closing a dialog box by clicking OK or Cancel. However, the similarities aren’t usually enough to tell you everything you need to know about the interface. The following sections offer an overview of the MATLAB interface so that you can work through the chapters that follow with greater ease. These sections don’t tell you everything about the interface, but you do get enough information to feel comfortable using MATLAB.
Starting MATLAB for the first time
When you start MATLAB for the first time (after you activate it), you see a display containing a series of blank windows. It’s not all that interesting just yet because you haven’t done anything with MATLAB. However, each of the windows has a special purpose, so it’s important to know which window to use when you want to perform a task.
You can arrange the windows in any order needed. Figure 2-1 shows the window arrangement used throughout the book, which may not precisely match your display. The “Changing the MATLAB layout” section, later in this chapter, tells you how to rearrange the windows so that you can see them the way that works best for you. Here’s a summary of the window functionality:
· Home tab: The Home tab of the Ribbon interface (a bar that provides access to various MATLAB features, such as creating a new script or importing data) is where you find most of the icons you use to create and use MATLAB formulas. It’s the tab you use most often. Also on the interface is a Plots tab (for creating graphic presentations of your formulas) and an Apps tab (for designing your own apps, obtaining new applications to use with MATLAB, installing apps, and packaging apps for use by others). MATLAB calls the Ribbon interface the Toolstrip, so that’s the name you see throughout the book.
· Quick Access toolbar: The Quick Access toolbar (QAT) provides access to the MATLAB features that you use most often. Finding icons on the QAT is often faster and easier than looking them up on the Toolstrip.
· Command Window: You type formulas and commands in this window. After you type the formula or command and press Enter, MATLAB determines what it should do with the information you typed. You see the Command Window used later in this chapter.
FIGURE 2-1: The initial view of MATLAB is pretty much empty space.
· Workspace window: The Workspace window contains the results of any tasks you ask MATLAB to perform. It provides a scratch pad of sorts that you use for calculations. The Workspace window and Command Window work hand in hand to provide you with a complete view of the work you perform using MATLAB.
· Command History window: In some cases, you want to reissue a formula or command. The Command History window acts as your memory and helps you restore formulas and commands that you used in the past. You see the Command History window used later in this chapter.
· Current Folder window: The Current Folder window contains a listing of the files you’ve created in the current folder — files you’d use to store any data you create in MATLAB, along with any scripts or functions you’d use to manipulate data.
· Details pane: The Details pane appears in the lower half of the Current Folder window and shows specifics about any file you select. Normally, this pane is hidden from view, and you display it by clicking the up-pointing arrow on the right side of the pane. To hide the pane again, click the down-pointing arrow on the right side.
· Current Folder toolbar and Address Field: The Current Folder toolbar helps you manage the current folder location on your storage device. The first four buttons let you move Back, Forward, Up One Level, or Browse for Folder. The Address Field text box appears next. Changing the Address Field text box content also changes the content of the Current Folder window. Clicking the down arrow in the Address Field shows a list of previous destinations from which to choose. The magnifying glass Search icon lets you perform searches for files based on filename, including wildcards (the ?), phrases, and extension.
Considering the default Toolstrip tabs
You always see the three same tabs as a starting point when working with MATLAB: Home, Plots, and Apps. Depending on what you’re doing, you may see other task-specific tabs, such as Editor, Publish, and View. The following sections describe general Toolstrip behavior and introduce you to the default tabs. As you perform specific tasks in the book, you also discover the task-specific tabs.
Showing and hiding the Toolstrip
You can minimize the Toolstrip by clicking the up-pointing arrow with a bar on top on the right side. When the Toolstrip is minimized, you can still see the three default tabs: Home, Plots, and Apps.
Click a tab to reveal the Toolstrip long enough to use a MATLAB feature. As soon as you select a Toolstrip feature or click in another MATLAB area, the Toolstrip disappears again. Using this technique allows you full access to the MATLAB features but keeps the Toolstrip hidden to save space.
To maximize the Toolstrip again, click one of the tabs to display the Toolstrip, and then click the thumbtack that appears on the right side after you select one of the tabs. The Toolstrip will appear at full size again.
The Home tab is where you spend most of your time when working with MATLAB to perform common tasks. It contains a number of sections, which divide the controls used to perform specific tasks. For example, to create a new script, you click the New Script button in the File section. You could also click the New drop-down list and choose Script from the list. Here’s how you use the various sections on the Home tab:
· File: Contains options for creating new files of various types, opening existing files, locating files on your storage device, and comparing two files.
Notice that there isn’t an option for saving a file on the Home tab. This option appears on the Editor tab when you create a new script or other code file that you need to save. MATLAB presents controls only when necessary to keep the interface simple.
· Variable: Provides methods for working with variables you create when doing one of the following: working with commands or various kinds of code; importing data from an external source; or clicking New Variable. The Save Workspace button lets you save variables to the storage device between sessions so that it’s easier to resume your thoughts.
· Code: Allows management of code items you create: functions, scripts, Live Functions, Live Scripts, and so on. You can also perform timings on your code and clear both the Command Window and the Command History window. You use the Editor, Publish, and View tabs that appear automatically when you create a new code item to actually work with the code.
· Environment: Helps you control the MATLAB environment by
· Changing the MATLAB layout
· Setting preferences
· Modifying the MATLAB search path used to look for files
· Managing add-ons such as toolboxes and products
· Resources: Links you to standard help options and community support. You can also request support from MathWorks. The Learn MATLAB option opens your browser to a page with links for online courses.
The Plots tab, shown in Figure 2-2, helps you create visualizations of your data using various plot types. The default plot types appear in the drop-down list in the Plots A section. To use any of the plots, you must first create one or more variables containing data to use in the plot.
Near the bottom of the plot list that appears when you click the down arrow button (not shown in Figure 2-2), you see a Catalog button that shows all the plots applicable to the data you select in a Plot Catalog window when clicked. If you can’t use a particular plot because your data doesn’t support it, the plot type appears grayed out in the Plot Catalog window. Don’t worry for now about drowning in a sea of plots; Chapters 6 and 7 explain them in detail for you.
FIGURE 2-2: Use the Plots tab entries to create graphic presentations of your data.
The Apps tab, shown in Figure 2-3, helps you work with apps, which are simply packaged and portable copies of code that you can type in the Command Window or store in a script, function, Live Script, Live Function, or class. The point is that apps are self-contained and do something interest. Part 3 of the book tells you about the various methods of creating and storing code, including creating apps (Chapter 14) and working with projects (Chapter 15).
FIGURE 2-3: Use the Apps tab entries to develop portable versions of your code.
The Apps section of this tab contains a list of apps you have installed. The Raspberry Pi Resource Monitor app is visible by default. This app lets you monitor resources and processes running on a Raspberry Pi (https://www.raspberrypi.org/) — an experimental computer that plugs into a wealth of devices and lets you perform a variety of tasks, such as learn about robotics.
Working with the Quick Access toolbar (QAT)
The Quick Access toolbar (QAT) makes commands that you select more accessible because you don’t have to select a tab to use them. You can change the QAT to meet your needs:
· To add an icon to the QAT, right-click its entry in the Ribbon/Toolstrip (such as, New Script on the Home tab) and choose Add to Quick Access Toolbar from the context menu.
· To remove an icon from the QAT, right-click its entry in the QAT and, from the context menu, choose Remove from the Quick Access Toolbar.
· To show a label for a particular icon on the QAT, right-click its entry in the QAT and choose Show Label from the context menu.
· To modify the QAT as a whole, right-click the QAT and choose Customize from the context menu. MATLAB displays the Preferences dialog box with the Toolbars entry selected and Quick Access selected in the Toolbar drop-down list, as shown in Figure 2-4. You must use this feature to perform tasks such as moving the icons around or adding a divider between icon groups.
FIGURE 2-4: Use the Preferences dialog to gain full access to the QAT configuration.
Employing the Command Window
The Command Window is where you perform most of your experimentation. This chapter shows how to perform simple tasks using the Command Window, but as the book progresses, you see that the Command Window can do quite a lot for you. You can type any formula or command desired in the Command Window and see a result. Of course, it pays to start with something basic so that you can get a feel for how this window works. Type 2 + 2 and press Enter in the Command Window. You see the results shown in Figure 2-5.
Typing a formula or command affects more than just the Command Window (which receives the output of the formula 2 + 2 with a result of ans = 4, in this example). MATLAB changes other windows as well. The Workspace window now contains a default variable named ans that contains the value 4. Variables are boxes (pieces of memory) in which you can place data. The Command History window displays formulas and commands that you type in the Command Window, along with the date and time you typed them. (If you don’t see the Command History window, type command history and press Enter in the Command Window.) To replay a formula or command in this window, just double-click its entry in the list.
FIGURE 2-5: A very simple command in MATLAB.
Getting additional help with MATLAB
The Help drop-down list in the Resources section of the Home tab contains a number of useful ways to obtain help with your copy of MATLAB besides relying on community support, paid support, and self-paced courses:
· Documentation: Provides descriptive, textual help. You can access the general help page through the Help drop-down list. However, you can also highlight a command, function, or other programming construct and press F1 to receive specific help about that MATLAB feature.
· Examples: Displays a window containing links to example applications you can try. Each application demonstrates a particular MATLAB feature, such as basic matrix operations. By following the example, you learn how to use MATLAB features in a hands-on environment.
· Support Web Site: Navigates to the MATLAB support site online, where you can find a wealth of other help resources, such as videos, apps other people have created, answers to common questions, error reports, and so on. You can access this site directly at https://www.mathworks.com/support.html.
Using the Current Folder toolbar
The Current Folder toolbar helps you navigate the Current Folder window with greater precision. Here is a description of each of the toolbar elements when viewed from left to right on the toolbar:
· Back: Moves you back one entry in the file history listing. MATLAB retains a history of the places you visit on the hard drive. You can move backward and forward through this list to get from one location to another quickly.
· Forward: Moves you forward one entry in the file history listing.
· Up One Level: Moves you one level up in the directory hierarchy. For example, when viewing Figure 2-9, if you are currently in the \MATLAB\Chapter02 folder, clicking this button takes you to the \MATLAB folder.
· Browse for Folder: Displays a Select a New Folder dialog box that you can use to view the hard drive content. Highlight the folder that you want to use and click Select to change the Current Folder window location to the selected folder.
· Address field: Contains the current folder information. Type a new value and press Enter to change the folder.
· Search: The Search icon, which looks like a magnifying glass and appears to the right of the Address field, changes the Address field into a search field. In that field, type the search criteria that you want to use and press Return. MATLAB displays the results for you in the Current Folder window.
Viewing the Current Folder window
The Current Folder window (refer to Figure 2-1) really does show the current folder listed in the Address field. The current version of MATLAB provides a tutorial application named tutorialApp.mlapp that you can load and view, or run to see what it does. To run the tutorial, type tutorialApp and press Enter in the Command Window, or right-click the entry in the Current Folder window and choose Run. The point is that this file is found in your default MATLAB folder.
When you first start MATLAB, the current folder always defaults to the MATLAB folder found in your user folder for the platform of your choice. For Windows users, that means the C:\Users\<User Name>\Documents\MATLAB folder (where <User Name> is your name). Burying your data way down deep in the operating system may seem like a good idea to the operating system vendor, but you can change the current folder location to something more convenient when desired. The following sections describe techniques for managing data and its storage location using MATLAB.
tutorialApp.MLAPP IS MISSING
You might find that your setup lacks tutorialApp.mlapp. Use these steps to create this file:
1. Select the Apps tab.
You see a list of app-related buttons.
2. Click Design App.
The App Designer Start Page appears.
3. Click the Interactive Tutorial entry in the Examples: General section.
A wizard appears to take you through the creation process. Notice that the name of this file is tutorialApp.mlapp.
4. Choose Save ⇒ Save Copy As in the File section of the Designer tab.
You see a Save Copy As dialog box.
5. Choose a location to save the tutorialApp.mlapp file; then click Save.
You’re ready to work with tutorialApp.mlapp.
6. Close the App Designer window.
The MATLAB window appears again.
Temporarily changing the current folder
There are times when you need to change the current folder. Perhaps your data is actually stored on a network drive, or you want to use a shared location so that others can see your data, or you simply want to use a more convenient location on your local drive. The following steps help you change the current folder:
1. Click Set Path in the Environment section on the Home tab.
You see the Set Path dialog box, shown in Figure 2-6.
This dialog box lists all the places the MATLAB searches for data, with the default location listed first. You can use the Move to Top, Move Up, Move Down, Move to Bottom, and Remove buttons to work with existing folders (go to Step 3 when you’re working with existing folders or to Step 2 to add a new folder):
· To set an existing folder as the default folder, highlight the folder in the list and click Move to Top.
· To stop using an existing folder, highlight the folder in the list and click Remove.
FIGURE 2-6: The Set Path dialog box contains a listing of folders that MATLAB searches for data.
2. Click Add Folder.
You see the Add Folder to Path dialog box, which looks like a standard file open dialog box. This dialog box lets you choose an existing folder that doesn’t appear in the current list or add a new folder to use:
· To use a folder that exists on your hard drive, use the dialog box’s tree structure to navigate to the folder, highlight its entry, and then click Select Folder.
· To create a new folder, highlight the parent folder in the dialog box’s tree structure, click New Folder, type the name of the folder, press Enter, and then click Select Folder.
3. Click Save.
MATLAB makes the folder you select the new default folder. (You may see a User Account Control dialog box when working with Windows; click Yes to allow Windows to perform the task.)
4. Click Close.
The Set Path dialog box closes.
5. Type the new location in the Address field.
The Current Folder display changes to show the new location.
Permanently changing the default folder
The default folder is the one that MATLAB uses when it starts. Setting a default folder saves you time because you don’t have to remember to change the current folder setting every time you want to work. If you have your default folder set to the location from which you work most of the time, you can usually get right to work and not worry too much about locations on the hard drive.
If you want to permanently change the default folder so that you see the same folder every time you start MATLAB, you must use the userpath() command. Even though this might seem like a really advanced technique, it isn’t hard. In fact, go ahead and set the userpath so that it points to the downloadable source for this book. Simply type userpath('C:\MATLAB2') (for MATLAB For Dummies, 2nd Edition) in the Command Window and press Enter. You need to change the path to wherever you placed the downloadable source.
To see what the default path is for yourself, type userpath and press Enter. MATLAB displays the current default folder.
Creating a new folder
Organizing the files that you create is important so that you can find them quickly when needed. To add a folder to the Current Folder window, right-click any clear area in the window and choose New ⇒ Folder from the context menu. MATLAB creates the new folder for you. Type the name you want to use for the new folder and press Enter.
Each chapter in this book uses a separate folder to store any files you create. When you obtain the downloadable source from the publisher’s site (http://www.dummies.com/go/MATLABFD2e), you find the files for this chapter in the \MATLAB2\Chapter02 folder. Every other chapter will follow the same pattern.
Saving a formula or command as a script
After you create a formula or command that you want to use to perform a number of calculations, be sure to save it to disk. Of course, you can save anything that you want to disk, even the simple formula that you typed earlier in this chapter. The following steps help you save any formula or command that you want to disk so that you can review it later:
1. Choose a location to save the formula or command in the Address field.
2. Right-click the formula or command that you want to save in the Command History window and choose Create Script from the context menu.
You see the Editor window, as shown in Figure 2-7. The script is currently untitled, so you see the script name as Untitled2*. (Figure 2-7 shows the Editor window undocked so that you can see it with greater ease; the “Changing the MATLAB layout” section, later in this chapter, tells how to undock windows so that you can get precisely the same look.)
FIGURE 2-7: The Editor turns your formula or command into a script.
If you want to select multiple commands to place in a script, you can choose them by clicking the first command and then using Ctrl+click to select any additional commands. Each time you Ctrl+click on a command, MATLAB highlights its entry. The commands will appear in the script file in the same order in which they appear in the Command History window, rather than in the order in which you click them. As an alternative, you can click the starting command and then Shift+click the ending command if you want to use all the commands within the group.
Note that you can also create a Live Script from your MATLAB formulas and commands. However, in most cases, you use scripts for simple tasks, so you don’t need to worry about Live Script for now. Chapter 11 discusses Live Script in detail and compares a Live Script to a regular MATLAB script.
3. Click Save on the Editor tab.
You see the Select File for Save As dialog box, as shown in Figure 2-8.
4. In the left pane, highlight the location you want to use to save the file.
FIGURE 2-8: Choose a location to save your script and provide a filename for it.
5. Type a name for the script in the File Name field.
The example uses FirstScript.m. However, when you save your own scripts, you should use a name that will help you remember the content of the file. Descriptive names are easy to remember and make precisely locating the script you want much easier later.
MATLAB filenames can start with only letters and numbers. You can’t use spaces in a MATLAB filename. However, you can use the underscore in place of a space after the first letter.
6. Click Save.
MATLAB saves the script for you so that you can reuse it later. The title bar changes to show the script name and its location on disk.
7. Close the Editor window.
The Current Folder window displays the folder and script file that you’ve created using the previous steps in this chapter, as shown in Figure 2-9.
FIGURE 2-9: The Current Folder window always shows the results of any changes you make.
Running a saved script
You can run any script by right-clicking its entry in the Current Folder window and choosing Run from the context menu. When you run a script, you see the script name in the Command Window, the output in the Workspace window, and the actual command in the Command History window.
Saving the current workspace to disk
Sometimes you might want to save your workspace to protect work in progress. The work may not be ready to turn into a script, but you want to save it before quitting for the day or simply to ensure that any useful work isn’t corrupted by errors you make later.
To save your workspace, click Save Workspace in the Variable section of the Home tab. You see a Save As dialog box that looks similar to the Select File for Save As dialog box (refer to Figure 2-8). Type a filename for your workspace, such as FirstWorkspace.mat, and click Save to save it. You see the new file added to the Current Folder window, as shown in Figure 2-9.
Workspaces use a .mat extension, while scripts have a .m extension. Make sure that you don’t confuse the two extensions. In addition, workspaces and scripts use different icons so that you can easily tell them apart in the Current Folder window.
Changing the MATLAB layout
The MATLAB layout is designed to make experimentation easy and comfortable for you. However, you may find after a while that it really doesn’t meet your needs. Fortunately, you can reconfigure the MATLAB layout to any configuration you want. The following sections provide ideas on how you can reconfigure the MATLAB layout.
Minimizing and maximizing windows
Sometimes you need to see more or less of a particular window. It’s possible to simply resize the windows, but you may want to see more or less of the window than resizing provides. In this case, you can minimize the window to keep it open but completely hidden from view, or maximize the window to allow it to take up the entire client area of the application.
On the right side of the title bar for each window, you see a down arrow. When you click this arrow, you see a menu of options for that window, such as the options shown in Figure 2-10 for the Current Folder window. To minimize a window, choose the Minimize option from this menu. Likewise, to maximize a window, choose the Maximize option from the menu.
FIGURE 2-10: The window menus contain options for changing the appearance of the window.
Eventually, you want to change the window size back to its original form. The Minimize or Maximize option on the menu is replaced by a Restore option when you change the window’s setup. Select this option to restore the window to its original size.
Opening and closing windows
In some cases, you may no longer need the information found in a particular window. When this happens, you can close the window. MATLAB doesn’t actually destroy the window contents, but the window itself is no longer accessible. To close a window that you don’t need, click the down arrow on the right side of the window and choose Close from the menu.
After you close a window, the down arrow is no longer accessible, so you can’t restore a closed window by using the menu options shown in Figure 2-10. To reopen a window, you click the down arrow on the Layout button in the Environment section of the Home tab. You see a list of layout options like the ones shown in Figure 2-11.
FIGURE 2-11: The Layout menu contains the layout options for MATLAB.
The Show group contains a listing of windows. Each window with a check mark next to it is opened for use (closed windows have no check mark). To open a window, click its entry. Clicking the entry places a check next to that window and opens it for you. The window is automatically sized to the size it was the last time you had it open.
You can also close windows using the options on the Layout menu. Simply click the check next to a window entry to close it.
Docking and undocking windows
Many people have multiple monitors attached to their systems. It’s often more efficient to perform the main part of your work on your main monitor and move supplementary windows to a second monitor. However, you really can’t move a window until you undock the window from MATLAB so that you can move just that window to another location.
To undock a window, click the down arrow on the right side of its title bar and choose Undock from the menu. The window becomes a separate entity, much like the Current Folder window shown previously in Figure 2-9. You can move the undocked window anywhere you want it, including to a second monitor.
At some point, you may decide that you want MATLAB to have all its windows in one place again. In this case, you click the down arrow on the right side of the window’s title bar and choose Dock from the menu. MATLAB places the window precisely where it was before you undocked it. However, the window may not return to its original size — you may need to resize it to make it fit as it did before.
Choosing an existing layout
One of the potential problems of changing your layout is that it may cause MATLAB to become nearly unusable. Rather than spend a lot of time trying to get the original layout back, you can simply choose an existing layout. To perform this task, click the down arrow on the Layout button in the Environment section of the Home tab and choose one of the Select Layout options. The Default entry returns MATLAB to the same state it was in when you started it the first time.
Saving a new layout
After you find the perfect layout for your needs, you want to save it to disk so that you can easily restore it later should the MATLAB display become disorganized (perhaps you’ve moved things about to perform a particular task). To perform this task, click the down arrow on the Layout button in the Environment section of the Home tab and choose Save Layout. You see the Save Layout dialog box. Type the name of the layout in the space provided and click OK. The layout now becomes available in the Select Layout section of the Layout menu.
To delete a saved layout, click the down arrow on the Layout button in the Environment section of the Home tab and choose Organize Layouts. You see the Organize Layouts dialog box, where you can rename or delete layouts that you’ve saved, but not the layouts provided with MATLAB.