Lesson 1.6:The MATLAB Help System

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[MUSIC]. We would have gotten the wrong answer, but MATLAB wouldn't have known it. And it wouldn't have told us anything. Errors of semantics are the biggest problem in computer science by far, because the rules that they violate are unknown to the language we're using, so we get no help. Makes you kind of like those red error messages. Well almost. MATLAB’s trying to help us with these error messages of course, but there's a lot more help easily available in MATLAB. I provides lots of commands like the who and whos commands that we use to look at the variables in a work space. And the clear command that we used earlier to remove all the variables from the workspace. All these commands are executed by giving their names, and every one of them has something called a help page, which is roughly a page, more or less, of explanations of the syntax and the semantics of the command. We've seen that we can get information about MATLAB's built-in functions by typing their names into the search bar up here at the top. But there's a command that we can enter that will print what we need to know right here in the command window. The name of the command is “help”. You just type help followed by the name of the command you want to to know about. Let's do that to find out about a command called “format”. [CLICKS] Here we see the so-called help page for the command format, or I should say we see the bottom of the help page, ‘cause it's a pretty long one, But we can scroll to the top by using the scroll bar over at the right or the mouse wheel or your fingers on the touch pad or however you like to do it. Every help page starts out by giving the command name, in this case “format”, and telling you, in just a few words, what the command does. So here we see: “Set output format.” This is followed by more detailed and more detailed ways that you can use the command and tells you what it does. You can read all about format later, but right now let's scroll down until we find “format compact” and “format loose”. Right here they are. You'll notice that COMPACT and LOOSE and these other options here are in upper case just to make em easier to spot when you sweep over this help page with your eyes. But you can use lower or upper case for the command. Most people use lower case. Let's see what these two options do. First I'm going to set x equal to five. Now let's use format loose [CLICKS]. And, I'll repeat the command. [CLICKS]. Do you see the difference? By “loose”, MATLAB means that spaces are inserted between the lines. I like a more compact output, myself. So I always change the setting to compact like this. [CLICKS] Now we're back to normal, or what I call normal. [CLICKS] If your particular MATLAB installation is set to loose, you may have been wondering why you're getting these spaces and I'm not. Now you know. And you might want to go with compact. Another thing that the format command can change for you is the number of decimal places that it shows when it prints a response to an assignment statement. We can scroll up and see these options. Let's see here, if I can find them. There they are. I've got MATLAB set to SHORT, which says, “Scaled fixed format to five digits.” Let's do another assignment statement. I'm going to do boy equals 117 divided by 19. There are an infinite number of digits in the exact answer. MATLAB shows five of them. 6.1579. Now let's try format long. [CLICKS] And I'll repeat that command. Let's use the up-arrow key to do that. Whoa! This time, we've got lots of decimals. MATLAB is showing you all the accuracy it's got. It's important to know,, though, that it works behind the scenes with all the accuracy it's got, whether you have the format set to long or short or anything else. All the command, format, affects is the printed output. You don't lose any accuracy during the calculations when the format is set to short. You just don't see all the accuracy in the output. I usually don't need to see all the accuracy, so I tend to stick with short. And that's what I'm going to do. And there we're back to five digits again. Let's see. Before I went off on this format tangent, I was talking about the help command. And I wanted to tell you some other things about it. For example, if you want to see the fancy documentation with the fancy fonts that you get when you use the search bar up here, you can also get that with a command called “docs”. So let's try that with format. There, all this nice stuff shows up. It is pretty handy. We won't go into it, but we've seen it before, and you can check it out. And here's another thing that we need to talk about. Suppose you don't know, you know, the name of the command that you're looking for. You want to do plotting, for example, so you could come up here and type plotting. And hit Return and, well, you see this window, and you say, “Oh, this looks good.” You see Plotting Basics. Click that: How To Create 2-D Graph, Add Title, Change the Limits. You know, “2-D graph”, that might be good. Create a line graph, 2-D. Oh, and here's some examples. It gives you a function. This is a workhorse function right here called plot x y. We're going to look at that in a minute. It shows you examples and so on. Now that you know plot is what you want you can type help plot, and scroll up here, and you'll see all kinds of information about plot command. There is a linear plot and so on. There is one other thing you can do. Let's go down here and look at this little thing. You've probably not noticed this before. This fx with this tiny down-arrow here. This is called “browse for functions”. Let's click on that. You see a little window show up here with some stuff that says MATLAB, language fundamentals, mathematics, graphics. I'm looking for plotting. That looks promising. Whoo, there you go! 2-D and 3-D Plots. I click there. Line Plots. And there is this plot function that I mentioned, and here is some information about it right here. So this is another way for you to find information about a function when you don't even know its name. You just browse for it. Let me just bring up Chrome and type “How do I plot in matlab?” Well! 2-D line plot. That looks promising. Let’s see what we get there. And there we are. That's exactly what we wanted. You'll usually get, not only the name of the appropriate function like this, but you'll be taken right to the help page that you need. MathWorks keeps all their documentation online so it's available to everyone. And Google’s search engine is so magical that, well, I usually wonder why I didn't just ask Google in the first place. [MUSIC] [APPLAUSE]
Info
Channel: Fitzle LLC
Views: 91,413
Rating: 4.9471364 out of 5
Keywords: MATLAB (Programming Language)
Id: _wxLhQy__6o
Channel Id: undefined
Length: 8min 37sec (517 seconds)
Published: Wed Apr 08 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.