MATLAB For Dummies
Book image
Explore Book Buy On Amazon

The MATLAB prompt is that place where you type formulas, commands, or functions or perform tasks using MATLAB. It appears in the Command window. Normally, the prompt appears as two greater-than signs (>>).

However, when working with some versions of MATLAB, you might see EDU>> (for the student version) or Trial>> (for the trial version) instead. No matter what you see as a prompt, you use it to know where to type information.

You can utilize a useful command known as clc. Try it now: Type clc and press Enter at the MATLAB prompt. If the Command window contains any information, MATLAB clears it for you.

The userpath() function is called a function because it uses parentheses to hold the data — also called arguments — you send to MATLAB. The clc command is a command because you don’t use parentheses with it. Whether something is a function or a command depends on how you use it.

The usage is called the function or command syntax (the grammar used to tell MATLAB what tasks to perform). It’s possible to use userpath() in either Function or Command form. When you see parentheses, you should expect to provide input with the function call (the act of typing the function and associated arguments, and then pressing Enter).

MATLAB is also case sensitive. That sounds dangerous, but all it really means is that CLC is different from Clc, which is also different from clc. Type CLC and press Enter at the MATLAB prompt. You see an error message. (MATLAB will also suggest the correct command, clc, but ignore the advice for right now by highlighting clc and pressing Delete.)

Next, type Clc and press Enter at the MATLAB prompt. This time, you see the same error because you made the “same” mistake — at least in the eyes of MATLAB. If you see this error message, don’t become confused simply because MATLAB didn’t provide a clear response to what you typed — just retype the command, being sure to type the command exactly as written.


Notice also the “Did you mean:” text that appears after the error message. Normally, MATLAB tries to help you fix any errors. In some cases, MATLAB can’t figure out what’s wrong, so it won’t provide any alternatives for you. Because MATLAB was able to provide the correct command in this case, simply press Enter to clear the Command window.

Look in the Command History window. Notice that there is a red line next to each of the errant commands you typed. These red lines tell you when you shouldn’t use a command or function again because it produced an error the first time. You should also avoid adding errant commands and functions to any scripts you create.

About This Article

This article is from the book:

About the book authors:

John Paul Mueller is an author and technical editor with experience in application development, database management, machine learning, and deep learning. He has written hundreds of books and articles helping everyday people learn everything from networking to database management.

John Mueller has produced 114 books and more than 600 articles on topics ranging from functional programming techniques to working with Amazon Web Services (AWS). Luca Massaron, a Google Developer Expert (GDE),??interprets big data and transforms it into smart data through simple and effective data mining and machine learning techniques.

This article can be found in the category: