Week+of+2-4+to+2-10

This week is somewhat thin because I spent a fair amount of time making the transition of the computer from QuarkNet to my house during a busy week of school work, so it was hard to find time to dedicate to researching. But, in my defense, I spent my usual amount of time doing things related to this class, it just wasn't work that I can show on this page. I also apologize for not posting this until the next week. One of the problems I had was getting the Internet connection squared away, so I originally wrote this post out in a Word document, and didn't realize I had neglected to post it on this Wiki. That being said, I'm back in business, and here's my short post for this week.

I picked up where I left off, about to begin to learn to communicate with the slider GUI through the command window. The first step in that process was to change a setting in GUIDE so that the program was actually accessible from the command line. A picture of the options window with the command line setting in a red box is shown below. The first step of actually communicating with the GUI, un-docking the command window, seemed sort of unnecessary at first, and then I realized it's actually extremely important. If the command window is in the IDE, clicking into the command window in order to type in it would actually make the GUI disappear behind the IDE. So, in order to do this, the command window needs to be undocked. To communicate with the GUI, you need to know the handle, which is unfortunately a number assigned by MATLAB that is not terribly convenient. 'findobj' is the magic command in this case. Below is a picture showing how calling up the handle works. As is clear here, the number MATLAB creates is just annoying, so rather than attempt to remember it, it is convention to do the programming thing and immediately toss it in a variable whose name is easy to remember. Below is a picture of what it looks like if finding the handle fails - namely, the variable becomes an empty matrix. This happens because 'findobj' returns the handle of all objects whose Property listed in the first parameter has the name listed in the second handle. So, rather than only the single handle in my first example, this command is actually ready to store a vector full of all the handles that have the characteristic you specified. In the case where none exist, it still returns the matrix, it just happens to have nothing in it. The first way of interacting with the GUI through the command window that the book introduces is the 'get' command, which returns whatever value you ask of it. Below is a picture of a certain position of the slider bar and the result of telling MATLAB to 'get' the 'Value' of the slider. The other basic thing a user can tell MATLAB to do with the GUI is to 'set' one of the values. Say I want my slider bar to be at exactly 9, which is difficult to do purely through sliding. Below is the way to do that. I included the 'get' line merely to show that I really had put the thing at exactly 9. One loophole about the 'set' pleasure that logically comes up is what happens if a user tries to set the bar to something outside the range of what it can be set to. Well, a message appears and the bar disappears. Below is the message that appears. The 'get' and 'set' commands can be applied to any GUI element, as shown below with a string. The final section of this chapter is 9.4, which addresses making information consistent between elements. As is obvious in the most recent image I posted, changing one of the GUI elements does nothing to the other. The text box changed to 3.33, but the slider bar stayed at the 1 position. In order to get these to coordinate with each other, the author directs the reader to the Callback commands inside the GUI code for each of the elements. Below are the commands changed in the SliderBar script in an effort to coordinate the two elements. In the Slider Callback, I am having it grab the Value and turn that into a string which it sets as the String value for the Text Box. In the Text Box Callback, I am having it grab the String and turn that into a number which it sets for the Slider's value. A link to a video showing the effectiveness of these changes is below (I am still having trouble uploading)

http://screencast.com/t/nkRWNsjB

That is it for Chapter 9 and for this week.