Week+of+11-26+to+12-2

November 26th
Today I arrived at QuarkNet at 4:15. My next step in familiarizing myself with MATLAB was to tackle the "Calling Functions" tab. It turned out that most of its contents were things I either already knew or were very easy to intuit. Using parenthesis to input arguments, separated with commas is something I have done time and time again. The same goes for assigning an output to a variable. One interesting new thing was the assignment of the same output to more than one variable using brackets. For, example, below I show how to tell the program that apples and mangoes are the cheapest fruits on the market. The use of brackets and variables separated by commas is the way to assign multiple variables to an output, as shown in my second command line. The effectiveness of this method was shown when I recalled the apple and mango prices and they in fact were the same value as the smallest price, 1. An odd problem I encountered is that apparently max and min can only handle two output arguments. I might figure out in the future whether the number of possible outputs is sensitive to the command or whether MATLAB will only allow you to assign two outputs to any command. The only other new thing for me was the possibility of entering a command without any parenthesis, such as the clc command. In Java, a command without inputs would have empty parenthesis after it, but the creators of MATLAB must have just though of that as a waste of space. Next I quickly checked out the "Help and Documentation" page. This one is pretty straightforward. The first part of it I looked at was the hint box shown below. It pops up if you pause before entering the inputs of a function, just in case you don't remember what kinds of inputs the function is capable of handling. This is further evidence of MATLAB's user-friendliness. The other two things addressed in the "Help and Documentation" page were the 'help' and 'doc' commands. These commands are executed by entering the command followed by a space, followed by the name of a function that the user is having some trouble with. The help command pulls up a very thorough definition and explanation of the capabilities of the function. Below is shown the result of calling 'help' for the max function. The doc command, on the other hand, pulls up a page in the Help window with a less wordy, more code-intensive feel. Next I decided to dive into the crash course on plots in MATLAB titled "2-D and 3-D Plots". I decided to put together a little project that showcases what I was able to learn about 2D plots. Below is the code and then the figure generated by the code. I think most of this code speaks for itself. The declaration of x (start, increment, end) and y (the function) is pretty simple, and the 'plot' function is straightforward, with the helpful third input which can designate differently styled lines to designate between multiple functions. The hold function is very useful, allowing multiple lines to share a plot. The axis function lets you choose a scale for the window if you want to override the auto scale. The labels for axes and title are just plain old strings, and the legend merely defaults to assigning the first string to the first line, etc. So, with that completed, I left QuarkNet today at 6:15.

November 28th
Today I arrived at QuarkNet at 4:15. I picked up where I left off yesterday, the "2-D and 3-D Plots" tab. I finished up everything I will do now for 2-D plots yesterday, so 3-D plots come next. Rather than come up with something clever like yesterday, I just made weird little 3-D graph, shown below along with its code below. The addition of a dimension causes the necessary parameters for the plot to be matrices, rather than vectors (one-dimensional arrays). An unfamiliar command, 'meshgrid', comes in great handy in the creation of some kind of 3-D plane. The command creates a square matrix where for the first variable each row is the array declared, and for the second variable each column is the array declared. 'meshgrid' separates the line or plane into sections which all get assigned a value-sensitive color. The maximum (z in 3-D, y in 2-D) gets assigned the darkest red, and the minimum the darkest blue, and the sections in between cover the spectrum between the two based on their value relative to the rest. The 'meshgrid' command is an easy yet useful foundation for many 3-D graphs. The 'surf' command is the other useful command for 3-D plots. It is the 3-D version of the 'plot' function, and is how you plot three variables (matrices) against each other. I spent some time trying to wrap my mind around the logic of creating a desired image from matrices assigned to the x and y directions, and I kept coming up short. The graph below of an odd little 3-D line is a pretty good representation of how odd my graphs looked. I am sure I will pick back up on 3-D plots later, but now is not the time for me to try to master them. The final component of the "2-D and 3-D Plots" page is Subplots. I am good with how to create subplots, but I do not understand their usefulness at this time. The main use of the 'subplot' command involves three parameters: width of the grid of subplots, height of the grid of subplots, and in which position the particular subplot concerned will go. I used the model for the creation of subplots the page used to create subplots for my first 3-D graph, and the results are shown below. The idea of showing parts of a graph and how they come together seems like it could be useful in certain situations. Aside from the subplot business, another new thing in this code is the 'mesh' command. This is a more free-form version of 'meshgrid'. I would describe the difference between the picture generated as 'mesh' being like a net and 'meshgrid' being like a blanket. That's as deep as I'll get into the world of 3-D plots for now, so I shall move on to "Programming and Scripts". It explains how the simplest form of MATLAB program is a script - a series of lines of MATLAB code. I created a relatively pointless addition script I will use to explain what I have learned about scripts, which is shown below along with one execution of it. It is 6:15 and I have to leave QuarkNet, but I will fully discuss this script in my next post.