[MUSIC] Welcome back. I hope you didn't have any trouble getting MATLAB, and that you're ready to start using it. So I've got two MATLAB desktops open here, as you can see. MATLAB Online on top, and my installed version at the bottom. And you should have one desktop open, either MATLAB Online, or your installed version. This is a good time for me to point out one big advantage of MATLAB Online over any installed version. Any computer tool that you access with your web browser, like MATLAB Online, will periodically improve without you having to do anything. One day it looks and behaves like, well this. And the next day or the next month, you may open it up and find that it looks a little different and it's got some new features. And that's a very good thing. With this auto updating of online tools, you don't have to install anything, and yet, you always have the latest and greatest version. The side effect is that the MATLAB Online that you see in this video might look slightly different from the MATLAB Online that you are running because you are out there in the future and I'm stuck back here in March 2018 using R2018a. But the difference won't be big unless you are so far in the future that you are wearing a silver jump suit and people are taking vacations on the moon. The generic name for tools like these, whether they are MATLAB Online or installed MATLAB, or Excel, or Chrome, or Call of Duty World War II, is Graphical User Interface. Or, using the initials as most programmers do, we call it a GUI, spelled G-U-I. And like any decent GUI, as we've seen, we can resize it and move it around on our computer screens, and we can use the mouse and the keyboard to interact with it. Inside each of these two MATLAB GUIs, we see three sub-windows. The current folder over here on the left and each of them. The Workspace over on the right. And the Command Window in the middle, which is labelled down here in the installed version, but it is not labelled up here in MATLAB Online for some reason. You can see that the three column layout is the default for the installed version, and I like that arrangement. But you can move things around a bit. To do that, just left-click the Window label, and while holding that left button down, drag it somewhere else. Say, let's drag this current folder window over here under the workspace. And it'll pop into place when you release the mouse. I hate this setup, so I'm going to put it right back where I had it. There. That's little too wide, let's move that back over there. And this is a little too wide. There, just right. Now, I'm happy as with my setup. By the way, if you quit MATLAB and restart it, it will remember where your last layout, so you don't have to keep moving things around every time. Okay, we've got command Windows, let's start commanding. We can look at the other windows later. If we left-click anywhere in a command window, say, up here in MATLAB Online like this, we'll see a little vertical bar start blinking on and off just to the right of this pair of greater than signs. That blinking bar tells us that MATLB is ready to receive a command. And that pair of greater than signs is MATLAB's prompt. And what's a prompt? Well, let's look it up in the textbook. We click on Glossary, and we see the first definition. Abstract class. Well, you can learn about abstract class toward the end of this book where we introduce the object oriented programming constructs in MATLAB. Object oriented programming's one of the advanced concepts that we mentioned that are beyond the scope of the course. Let's type prompt into the search bar. There it is. There's our definition. A prompt is a symbol or symbols printed by a program, MATLAB is an example, to indicate it is ready for input from the user of the program. MATLAB uses the prompt greater than, greater than. To input a command, you type it on the keyboard, and that blinking bar shows you where it will appear, which is just to the right of the prompt. So are you ready, commander? It's time to issue your first command. I don't know about you, but I am pretty excited. And here is the command we're going to give. Type x space equals space 1 space plus space 2. And hit Return. Or it might be Enter on your computer. All right, here we go. Okay, maybe I built that up a little too much. Here, let me do the same thing in the installed version. And let's think what just happened. In each desktop, MATLAB created a variable named x, calculated 1 plus 2, stored the result, which is 3 and x, and then printed the value of x. I should say lower case x because if I'd use an upper case X that would be a different variable. And all those spaces around the equals sign and the plus sign, not necessary. I just included them to make it look prettier. Here, let's leave all of them out. Works the same. Spaces are used in MATLAB, but they're often not needed. Usually, you'll find that if you can make sense of what you typed with or without spaces, then MATLAB can, too. Speaking of space, I don't like all those vertical spaces between the lines that MATLAB keeps putting there. It does that by default, but we can stop that by giving this command. Format compact. Now, let's type x equals 1 plus 2 again. No, wait, that's way too much work. Man, I can't be dealing with typing all kinds of characters over and over just to get to same command twice. No, that's not for me, I'm a man of efficiency. Instead, I will just hit the up arrow on my keyboard two times. That pops up the last command I typed, and then the one before that. And now, all I'll have to do is hit Enter. Bam. And there it is. And this time, all those useless screen hogging annoying, terrible, horrible, no good, very bad, vertical spaces are gone. When I used that up arrow to see previous commands, MATLAB showed us its so-called command history window. The command history is an extremely handy feature of the desktop, and you'll find yourself using it a lot. And we'll use it in this course. Let's hit the up arrow again. And this time, we'll click this tiny down arrow here, and select Dock. When we do that, the Command History window is no longer a pop-up window, but is right there all the time if you look at it. It ended up right over here, under the Workspace. You can scroll around. Double click a command to put it in the Command Window, where you can hit Return to execute it. Or you can just drag one over here to execute it, hit Return, and there it goes. Of course MATLAB Online has a command history, too. While we've been neglecting it up here, it has timed out, no problem, we just log back in again, it will come right back. And you can use the Up arrow to run previous commands. And as you can see, it remembers the previous commands from one login to another, there is a difference, though. When you hit the up arrow in MATLAB Online, only one command appears at the time, not the entire history. Okay, I'll hit Return to execute it, ugh, it's still double spacing, let's fix that. There. When you want to see the entire history in MATLAB Online, you can click up here on Show History, and it appears in a pop-up window. You can move it around, change its size. You can't drag and drop commands, but you can double click them to run them, so. There, I ran that one, and another one. It doesn't change the spacing because we've already used it, but I just ran the format compact again. Okay, that's it for the Command History. But before we move on, let's tidy up the Command Window, it's gotten very cluttered. There are buttons for that in both versions. But I like to type more than click, so I'll use a command to do it, clc, clear command window. There, I'll do it in the installed version, too. That's much better, and I'll undock the Command History. Undock. So both desktops have the same layout, okay. Okay, it's important to get the layout you want for efficient programming. And now you know how to arrange things and how to see the Command History. And you know how to use the Format command to change to single spacing. There are many other formats that you can change also, such as the number of digits that are printed to the right of the decimal point. If you want to see all the formats that you can request with the command Format. Or if you want information about any command whose name you know. You can look it up via the Search Documentation field right up here to the right on the top of the MATLAB desktop. You just type in, Format, or whatever you are looking for, and hit Return. And up pops a window with information wherever the word Format shows up, we'll look at this more closely later on. Before we go further, it's important for you to know how to regain control of MATLAB if it's taking too long to process command. The method is different in the online and install versions. We'll start with the online version. First I'm going to give a command that will take way too long to complete. R-a-n-d. That's seven zeros, my friend, and this command tells MATLAB to cough up 10 million random numbers. Okay, I'm going to hit Return and step back. Whoa, and here they come, by the hundreds. And the thousands, and eventually the millions. Well, this is getting boring, but right down here, look at this little button. It says Stop, let's try clicking that. And give it a double click. Try it again. Sometimes I've noticed it takes a couple of clicks if you've let a lot of stuff pour out onto your window. But that will stop it. And that's how you rope, throw, and tie this little dogie. [LAUGH] That's my rodeo talk, shows how cool I am. It means that's how you stop MATLAB Online. Now let's give the same command in the installed version. 1, 2, 3, 4, 5, 6, 7, Return. And here they come. Where is the Stop button? Well, you can look until the cows come home, I'm still on my cowboy theme, but you won't find one, partner. To stop this version, or any installed version of MATLAB, you need to use a special combination of keys called Ctrl+C. Which is done by holding down the Ctrl key, it may just say C-T-R-L on your computer. And while you're holding it down, hit the C key, there, that's a little more responsive. Looks like this little filly knows who's boss. What, you didn't know MATLAB was a female? I would have thought the bigger surprise would be that it's a horse. And if you want to get off this horse, you can quit MATLAB by typing, guess what? Quit. Q-u-i-t. And when you hit Return, MATLAB will go away. You can also left click this red dot here up at the top, top left, on which an x shows up when you get close to it. Or if you're on Windows, you can click the x at the top right, which turns red when you get to it. Hey, Apple and Microsoft, isn't this feud a little silly? Anyway, another method is to click this tiny down arrow, up here at the top right and log out of the online version. MATLAB will ask you if you really want to leave, and you'll confirm your choice, and you'll be right back to the login screen. But this is no time to quit, we need to get back to our variable x. First, I'm going to clear the screen, by typing clc and hitting Return, there. I'll do that down here, too. Okay, back to the variable x, we call x a variable because its value you can vary. But that value always stays the same until we assign it a new value, like this. When we do that, the old value, in these case, 3 is gone, that's not special with MATLAB. Every programming language provides variables like this, manages locations in the computer's memory to hold their value. In fact, the definition of a variable in computer science is simply a location in memory that has a name and a value. The form of an assignment statement in MATLAB and in almost all computer languages for that matter is the same as it's been since 1957 when Fortran appeared. You type the variable's name, then the equals sign, then an expression, like 1 + 2 or just 4.7. It bears repeating that when we told MATLAB to assign 3 in the first place to x, it did not yet exist. That was not a problem because MATLAB created it right on the spot. All you have to do to get a variable with the name you wish it to have is to assign a value to it, and the magic genie MATLAB will grant your wish. This is not true for Fortran, it's not true for C, C++, or Java, they require a lot of setup work to create a variable. That's one of the things that makes MATLAB simple to use and one of the reasons. That Moler's students prefer to do Fortran after he'd invented MATLAB for them 40 years ago. The sort of programs that are typically written in C, C++, and Java, there are good reasons for requiring all that setup work. But it's a lot easier to get a program written if you can get along without it, and with MATLAB, we can. Okay, now let's just type our variable's name without assigning it anything. This time l am going to do in MATLAB online only because the installed version does exactly the same thing. Let's set X equal to 4.7 up here too and then just hit plain old X, this time MatLab tells us the value of x. It's not so helpful now but very helpful if you've given 50 commands since you assigned the value to x and you can't remember what the value is. Again, there may be a bit more going on, it might be obvious. MATLAB has just searched this memory for the variable named x, found it, checked it's value. Discovered that it's 4.7, and then printed 4.7 in the command window. Now let's ask it to look for another variable, how about y? Oops, red type is never a good thing in MATLAB. I've been programming MATLAB for 20 years and I still get a little sting when I see one of these red error messages. MATLAB is telling us that y does not exist, it says, Undefined function or variable "y" because functions can have names like y or x too. And MATLAB thought maybe we were trying to run a function. A function is simply an operation that happens when you give it's name, you don't believe me check the book, an operation that is invoked by giving its name. The computer science definition is in contrast to the mathematical definition which is any operation that produces a result that depends only on its input. A MATLAB keyword and introduces a function declaration in the function's M-file, so it's a keyword in MATLAB. Well, invoked, ooh, fancy, and I guess I left out the stuff about the difference between the computer science definition and the mathematical definition. But why do we even need to know about the mathematical definition in a book about programming? If you ask me, whoever wrote this book is just showing off. I will admit the last thing here about the MATLAB keyword, it's good to know, we'll get to that a little later. Anyway, we've already invoked a function by giving its name, remember when I typed this, The function ran, And all those numbers came flooding out? Well I didn't press return this time. Rand is a function and we invoked it by typing it's name, the name stands for random and the operation it performs is to calculate random numbers. These two numbers in parenthesis, 10 million and 1 are inputs that the function used to calculate its output. Let's erase this thing before it gets us into any more trouble. I'm going to click left and hold the button down and sweep over it and hit the delete key, there! However, if you just want one random number instead of 10 million of them, you can type this. [SOUND] Rand without any inputs gives you one random number between 0 and 1. There are lots of handy functions in MATLAB, in fact, that's one of its strong points, but there is no function named y. Since there is no function and no variable named y, MATLAB complained. Not sure why MATLAB mentions function before variable, maybe it is alphabetical. And by the way, let us clear up any confusion between the word command and the word function, they mean exactly the same thing in MATLAB. This documentation doesn't distinguish between these two synonyms but it uses the word function more often than it uses the word command, at least in my experience. You may have noticed that things have been popping up over here in the workspace. In MATLAB, the workspace is the set of variables that we have available to us. You can find the fancy schmancy definition in the textbook but you don't need that yet. The workspaces in the online and installed versions look a little different. The online version gives some extra information about each variable, we'll learn what all that means later. But right now, what you need to know is the name of the variable and its value, and that's there in both versions, so what is this variable ans? Well this is a special MATLAB variable whose name suggests that it holds the answer, and it does. It's created automatically to hold the result of any calculation that's not assigned to a variable by the user. And except for the fact that MATLAB assigns values automatically, it's a normal variable. It's very handy because if you calculate something, don't assign it to a variable, and then you wish you'd assigned it to a variable, say zebra. Then all you have to do is this. And 0 has the value 0.8147, so you know how to create variables, how do you delete them? There's usually no reason to delete them but if you want to reduce the workspace clutter, you can do one of two things. You can use the clear command like this, And zebra's gone, or you can right-click the variable in the workspace, choose Delete, And it's gone, note that zebra is pink in this clear command, or is that purple? Anyway MATLAB uses purplish pink to mean that the name zebra is being given to the command clear instead of the value of zebra. Clear is not removing the five from the variable zebra, it's removing the variable zebra from the workspace That's confusing, forget it. The reason for the color is not that important. I brought it up because you might want to know your eyes aren't playing tricks on you. Well, a couple of other things about the command Clear. First, you can tell it to clear two or more variables. And second, if you give the Clear command without telling it which variables to clear, it clears every variable in the workspace. Let's create four variables. Lions, Tigers, Bears. And one more, Ohm_eye. Now I'll give the the value of the sum of those three variables. Yes, you can use underscore as part of a variable name. And you can use stupid names. There are a few limitations, but almost any name you'll want to use is okay. We'll give you the rules for names later. It's simple. If you're wondering about the order of the variables in the workspace, it's alphabetical. And you can reverse the order by clicking this little arrow here, little upward triangle. There, so now let's get rid of two of them with Clear, Lions and Ohm_eye. Now we got three to go. Let's clear them this way. Clear with nothing after it, gets rid of everything, and they're all gone. I'm sure you've been noticing things popping up while I'm typing such as, This is a list of functions that start with the letters cl. If you see one you want to invoke, you can select it and hit the Tab key and it will be typed for you like this one. And I can hit Return, and it'll do nothing because it's already clear. This is called tab completion, works a bit differently in the installed version. There you hit the Tab key once to pop up the list, and then it's the same. Here's another example. This time, I typed. The name of the function, and a left parenthesis, like I'm getting ready to put an input in there, and what pops up is called a function hint. It reminds me what inputs I can give this function. Okay. Let's clean up by clearing the command window. This time I'll do it with the Clear Commands button up here. And let's do it down here, too. But first, I'll clear the workspace over here. Instead of using the Clear Command, I'll use Clear Workspace. And they're gone. And now I'll clear this window and I'll use Clear Commands down here. Good, all tidied up, neat and nice. Okay, we've looked at the command window and the workspace window, but we haven't looked at the current folder window over here. For both versions of MATLAB, the current folder is the place where MATLAB saves the files that contain the programs that you write. And it's the first place to look to find files that hold programs that it needs to run. To learn about the current folder window, let's start up here with MATLAB online. First question is, where is this folder? Well, for starters, it's not on your computer. The current folder is inside a computer that's maintained by the MathWorks with space set aside for your use and only your use. When you got your account, login and password, you're instantly allocated space and given access to it through this folder. The name of the folder is MATLAB Drive. And you can see the name right here in this white area, which is called the address field. We will show in a little bit how you can copy stuff between your MATLAB drive and your computer, but for now we'll just focus on the MATLAB Drive itself. This bar above these three windows is called the current folder toolbar. And we're going to be looking at everything in it. We've already looked at one thing, the address field. And that's this part right here. The name of the current folder is always shown in the address field. The stuff inside the current folder is always shown in the current folder window. There's not a lot to begin with there, just two folders, one named published, and one named shared. I'm not going to use these folders, but someday you may find them handy after you've completed this course as a full-fledged MATLAB programmer. And you start working on shared projects with other people, people anywhere in the world that have access to the Internet. If you want to learn about these folders and other things we don't have time to cover in this introduction, you can find some documents on MATLAB online in the course resource links. Well, let's put some things in the current folder, the current folder which is MATLAB Drive. Suppose I want to have a folder in there named First Lesson. Well, I come up here and click this big yellow plus sign and select Folder. This little window pops up and I type the name. And either left-click OK, or hit the Return key. And there it is. Now I want you to watch carefully. I'm going to double-click my new folder, and that will make it my new current folder. I'll double-click on the count of three while you watch the address field. One, two, three, click. And as promised, its name is there in the address field. But why is the previous current folder MATLAB Drive still there, too? Well, if you can wait a minute, I'll explain it. First, let's put something in First Lesson. I want two folders, Studying the Textbook and Using MATLAB, the two things you need to do to succeed in this course. I'll do it quickly. There, now the current folder window shows that there are two folders in the current folder. Which is first lesson. Now let's change our current directory to Studying the textbook. Remember how you do that? Just double-click it. Okay, now you can see why a MATLAB Drive was there. The address field shows you the path you would have to go from the MATLAB Drive, which holds everything, to Studying the textbook. You have first go into First Lesson and then into Studying the textbook. In computer science terms, the folder named Studying the textbook is a so-called child of First Lesson, which is its parent. And First Lesson is a child MATLAB Drive. You might be tempted to call Studying the textbook, the grandchild of MATLAB Drive. Don't, nobody says that, people will make fun of you. Yeah, and I'm still scarred by it, and no grandparents either. And a folder has just one parent, not like you and me, we have two. The parent is considered to be a higher level in the folder hierarchy than its children. Siblings are at the same level. And the folder at the highest level, in this case MATLAB Drive, is called the root folder. It's hard to picture the root being at the top instead of at the bottom, just picture an upside down tree that's what I do. One last thing about folders, another name for a folder is a directory. And some MATLAB commands use that terminology. In fact you may hear me occasionally slip up and call a folder a directory. That's what I was taught to call them when I first learned about all this stuff using UNIX in 1980. What's UNIX, well just Google it. Now let's do some stuff with the current folder, in the installed version. When MATLAB started the first time, right after its installation, it did a couple of things for me regarding folders. The first thing it did was create this folder named MATLAB, as a child of Documents. Which is a child of fitzpajm, which is a child of Users, which is the root folder. You probably figured out from this, that my user name is fitzpajm. Let's keep this on the downlow because if it gets out it might be a security risk. Stands for John Michael Fitzpatrick, and I just celebrated Saint Patrick's Day, which is, well just Google it. You'll have your own user name there, of course. The other thing that happened when MATLAB started is that it made MATLAB the current directory. Oops, sorry, it made MATLAB the current folder. You can think of this MATLAB folder as similar to the MATLAB Drive folder up here, except that this folder, and all these folders are sitting down here inside My Computer, not up in the cloud. Okay, so let's put a folder in here. I'm going to name it Lesson 1 instead of First Lesson, so we won't get it confused with the folder up here in the cloud. A couple of ways to add a folder with the installed version. First, you can left-click the tiny down triangle up here at the top right of the current folder window and select New Folder. Second, you can right click inside the window itself and select New Folder. Which is the way I like to do it because it's easier to hit this big window with a click than that teenie weenie triangle. Now I have a folder named New Folder. I'll change its name by right-clicking it, selecting Rename, and typing the name I want, Lesson 1, there. As before, I'll quickly add Studying the textbook and Using MATLAB in there. This address field is not just a pretty place to see the path from the root folder to the current folder. You can use it to navigate, too, and it works exactly the same in each version, so I'll demonstrate it in MATLAB Online. If you left-click one of these little triangular separators, like this one. You see a list of the children of the folder to the left. And if you select one of them with a left-click like this, It becomes the current folder. And like this. And like this. And you can left-click any of the names in the path to go there. Back to First Lesson and back to MATLAB Drive. And over here on the right, you can see a list of recent current folders by clicking this this little down arrow, And all this, and if there are too many, a scroll bar will appear over here on the right so you can see more. You can go to anyone of them by clicking on it. I'll go to Published just for fun. This is fun, right? We're having fun. Aren't we a little bit? Well get ready for even more fun folks because in case you haven't seen enough ways to navigate through your folders, we've got four more. Over here at the far left end of the current folder tool bar, is the so called back arrow which takes you to the last current directory before now. Which in these case was MATLAB Drive, and when you go back, this forward arrow lights up, this one undoes the back arrow's work. Frankly l find the forward arrow to be more confusing than useful, but if l click it now, we go back to Published. Wait, clicking forward took us back to where we were before we clicked back. Wow, see? Is that confusing or what? I just don't use it. Just to the right of these two arrows is a little icon showing a folder with a microscopic black up arrow on it. If I hover the mouse over it, you'll see it's name Up One Level. So, which way is up? Well, up is toward the parent to the current folder, which as we mentioned, is considered to be higher than its children. As we can see from the address field, the parent of the current folder is MATLAB Drive. So, another way to explain this button, is to say that it moves you to the left one step in the address field. So let's click it. And our current folder becomes MATLAB Drive. Both these arrows and the Up One Level icon work in exactly the same way in the install version. All this work and we're right back where we started. Man, let's get out of here, I happen to know about a hidden door, right here. It's this little icon of an open folder with a tiny green arrow curving down. We hover over it, and we see its name. Browse for folder. We click that, and what, This pop up is only partially displayed, it's because my browser window is too small, let's make it bigger. There, oddly the name of the window is different from the name of the button that opened it. Select a New Folder instead of Browse for Folder, but the idea's the same. And it works like the browser on your computer, but a little slower in MATLAB Online. It shows the available file system. This folder up here, named MATLAB Add-Ons, comes with the installation all set up to allow you to add things that you purchased from the MATLAB store. Don't worry, you don't have to purchase anything for this course. You and I are going to build all the things we need in our own little workshop with a mouse and a keyboard. But if you do want to buy something, you can shop at the Add-Ons store by clicking up here, On this little stack of red, green, and blue blocks. And you're at the store. The browse button for the installed version works the same way. First I'm going to adjust things a little bit There. The difference with the installed version's browser button is that it opens the Finder on Mac or File Explorer on Windows, or whatever browser your operating systems happens to provide. And you can navigate any folder on your computer and make it the current folder when you go to MATLAB. There, like that. Okay, one last thing on the current folder toolbar, here if you can stand it. Hey look if I can stand it, you can stand it. Okay, way over here on the right, is this little magnifying glass, which is the universal symbol for search. If you click it, then you can type the name of the file you want to find, over here. Hit Return and it'll look for it in the current folder and then the children of the current folder and all their descendants. But we don't have any files to search for, we got folders, we got children of folders, but we got no files. Let's create one. I'll click this X to end my file search. And then to create a file, I'll use a tool in this grey up here. We've already sneaked up here and clicked a thing or two, but we haven't really talked about it. The area above the current folder toolbar is called the tool strip, and it contains so called global tabs. They're global because they're always there no matter what you're doing with MATLAB. The HOME tab is on top of PLOTS tab and APPS tab. If I click the PLOTS tab, it comes to the top where can see it, and the same for the APPS tab. But we'll spend most of our time with HOME on top. Let's click the New Script button over here on the left. It's asking for a New Script name and it's already put an extension for the file name, the dot and the m. I'm going to type pretty_picture in front of the dot and click OK. A couple of things have happened. First, three new global tabs appear, the EDITOR, PUBLISH, and FILE VERSIONS. Second, when the window appeared here, this is the EDITOR window, it's where we'll type our MATLAB programs. Actually, instead of programs I should say more precisely functions. We're going to create functions and then run them by typing their names in the command window. MATLAB will then run them. In this scenario, MATLAB is the program and the function is part of the program. While you've got its desktop open, MATLAB is running. If you want that program to do your bidding, you write a function and invoke it, giving its name in the command window. You write functions by typing MATLAB commands into the EDITOR window. And for most of this course, that's all you're going to do. We'll teach you all about it, but right now, all I want to do is paste the function in there that I've copied from the MathWorks website. It was written by Cleve Moler and Jack Little back in the 1980s. I've copied it and now I'll put my mouse into the editor window and hit Command+V, Which is done by holding down the Command button while hitting the V key. If you're running MATLAB on a Windows system, instead of the command key, you use the Ctrl key. Now, I'll go over here in the EDITOR window, and click the Save button, it just turned blue. There, we have stored the MATLAB code that you see in the EDITOR window into the file named pretty_picture.m. Let's stretch the desktop down a little bit so, we can see the whole function. There. It's too early in the course for me to explain how this function works, but I will mention one thing about it. All those lines that start with a percent sign, the ones that are green, are referred to as comments, which means comments to the user of the function. They're not MATLAB commands, but they are important. They help people understand how the function works, where it came from, and how to use it. For example, this comment, Tells us that we should give the command an input and that a good input to use is the number 500. Now we're ready to run it. We run functions that we've written in exactly the same way as we run built in functions, like rand and clear and format. We type its name and if it required inputs, we add them in parentheses. Well, that is a pretty picture. And notice that a new global tab showed up here in the tool strip named FIGURE. It lets you change the way the picture is presented, but we'll leave it like it is. I wonder what would happen if I changed 500 to 1,000. I'm going to hit up arrow, click left there on my keyboard, come over here, hit Delete, and hit 1,0 and Return. What about 100? It's interesting how much complexity you can get out of five lines of MATLAB. One, two, three, four, five, well six counting this one up here. The comments don't count because MATLAB doesn't even use them. The C-O-S here, by the way, means cosine and S-I-N means sine. These are built in MATLAB functions that are being invoked by our function. Let's change cosine to sine, and see what happens. Then hit up here, and run it again. What, my fault, I forgot to save it. See this blue, this means we're supposed to save it first. I'll save it, forgetting to save changes before running is a very common human error. At least, that's what I keep telling myself. MATLAB Online will save automatically for you about once a minute. But you'll find that when you're correcting errors in a function, you'll need to save more often than that. Installed version saves as soon as you click anywhere outside the editor window, so you don't need to remember to save. But with the online version, you need to remember to do it yourself. So I've saved this time, but if you would, please remind me to save next time, my memory is not the best. So I'm going to run it again, up arrow. Well, that's disappointing, I'll try changing the second one to T-A-N for tangent. Well, it's not bad, it's not as boring as a straight line, at least. How about changing this sine to tangent too, and see what happens, and here we go. Oops, [LAUGH] thanks for reminding me, I would definitely have forgotten this time, I'll save it. Up arrow again, And here we go with another straight line. Okay, I've saved several versions of this file, and now suppose I want to go back to a previous version. Well, I can click this tab labeled file versions, click this down arrow, and it shows me how many versions I've made. These are versions I made while you were watching me, these are the ones I made before as I was working on this video for you. I can pick any version I want, let's pick this one. That's the one we had, Or I can click this button named Older and go back one step, I can go Newer, and go forward one step. And I can click Restore as Latest and give whatever version that's in the editor window at the time the timestamp right now, as the latest version. Okay, I've fiddled with changes to this file just so I could tell you about file versions. Now I am so done with this function, let's close its editor by clicking this little x right here. Let's go over here, in the current folder window, click right on this thing, and let's delete it. Yes, I am sure I want to delete this file, because for this, Nuts, I should've kept this thing in case I have to reshoot this video. [LAUGH] Well, guess what, MATLAB is going to come to my rescue. You can get deleted files back. No, there's no tab for it, but there is a website. I'm going to use the URL, https://drive.matlab, and you can see I've been there before, .com. Usually have to log in to this just like you logged in to your regular account. But I logged in a few minutes ago, so they save us some time here. Well, look here, there's my MATLAB drive, there's First Lesson, and there's Published. It's all here, there's no Shared because as I mentioned, Shared is not really a proper folder. If I click this little arrow, I get to see what's inside here, but it's all here. Down here at the bottom left, we see how much space we've used, 254 KB. I have 5 GB, you'll have only 250, I've got the 5 GB because of a license Vanderbilt has. But you won't need, look, this is a 1,000th of 254 megabytes, so you're in good shape. But there's something more important here in this page than that. Look over here at this one, deleted files. It will show us the files that we've deleted since we started using MATLAB Online. Let's click that, wow, I didn't realize I'd deleted that much stuff. I do remember this file, adsf, made it by accident. I think I'll permanently delete it because I know I'll never need that. To do that, I click right on it and pick Permanently Delete. And of course, it says, do you really want to permanently delete? Folks, there's no coming back from this, so, yep, gone. Doing that doesn't affect the space you've used because deleted files don't count against your total allotment. And speaking of permanently deleting things, any file that stays in the deleted folder for 30 days will automatically be deleted. So let's scroll down and look for the file we want, there it is, pretty picture. To restore it, couple ways, you can click Restore up here. Or you can click right and chose Restore, and isn't that reassuring? Pretty picture restored to MATLAB drive. Go to location, I'm just going to click here, and there it is. Okay, let's move this up a little bit. I'd like to have the same function in my installed version for MATLAB, pretty picture. I could click New Script in the Home tab, which will open up the editor window and do all the things we did before in MATLAB Online. But that would be repetitious, and more importantly, there is a much easier way. Now that we've got the pretty picture file ready to go, I'm going to download the file from the cloud onto my computer. First I highlight the file by left-clicking it. Then I click this Download button in the Home tab. What happens then depends on the way you've set up your browser. I have mine set up to download things to my download folder, so I'm going to look there. I open up Finder, go into Downloads, and folks, there it is, pretty picture. And that's down here on my computer. It showed up here at the top because I keep my Downloads folder organized so that the latest things are at the top. I'm going to copy it, Go to my MATLAB folder, which I also have in Favorites, navigate to Using MATLAB And move it there. There we go, it's come down here. Let's look in there using MATLAB. There it is, and we're ready to run it, let's do that. And there it is, but in the installed version, it appears in a floating window instead of being docked inside the desktop. It looks even better when it's bigger. Reverting to an earlier version of file and restoring a deleted file is not a built in part of installed MATLAB. There are lots of third party options for that, though. I use Dropbox Professional, which provides it, and believe me, it has saved me more than once. Okay, I'm going to clear things up. Make this a little bit smaller. And let's get rid of this bar showing downloading files by clicking this x over here on the right, there. And I can pull this down a little bit. Okay, so that's how you get earlier versions and undelete files in MATLAB Online. Okay, we just downloaded a file from the MATLAB Online cloud to my computer. Now, let's upload one from my computer to the cloud. Nothing could be easier, first, I find the file I want in my finder. Here's where I want, this JPEG file, I could use the Upload button, up here. But I prefer to left click the file, Hold down the left button, and drag it over here to the current folder. And there it is, and maybe you'd like to see the picture in this file, well, that's also easy with MATLAB. You can type the built in function, imshow, and give it an input of the name of the file. Notice that I put the file name inside single quotes. Is it me or is that a little small, let's make it bigger. That's a little bit better. You can read all about making and displaying images with MATLAB in the textbook. Just look up image processing in the glossary and click the blue link at the bottom of the page. All this uploading and downloading can be automated. MathWorks provides a tool called the MATLAB Drive Connector. That will continually synchronize the files in your MATLAB drive with a folder on your computer. When you change something in one place, it's changed in the other. When you add a folder or a file or delete something, it happens in both places. You can find out how to get it done in the resource section of this course. Well, what have we learned in this video? Well, lots of stuff, we've learned how to use the folder and file system. We've learned how to write and run a function. And we learned how to use a command window, the workspace, and the command history. And these things are going to come in very handy in the next video. Well, as we gaze at this beautiful aqueduct in the south of France, and as we perhaps wish that we were there, or in my case, wish that I was back there again. We'll end this this video, get in our time machine and return to those early days in the fall of 2014. When I explained how you could use MATLAB as a calculator, a very powerful calculator, I'll see you four years ago. [MUSIC].