Week+of+3-4+to+3-10

This week's post will consist of cleaning up the poor straight line GUI I created a few weeks ago. To begin, I had to envision how I would make this GUI more interesting and user-friendly. I decided that I needed to scrap the weird x-min and x-max that then determines the y-axis as well in order to fit in all points. Instead, I figured it would be more useful to be able to set a center point for each axis and then have the GUI scale out a certain amount in each direction from that center. This way, essentially any axis can be set, and it is a fresh difference from the usual choosing a min and a max for each axis. I also decided that the slope and y-intercept edit boxes also needed accompanying slider bars. Also, I figured it might be interesting for the user to compare lines. So, I decided to insert two buttons: one that allows the user to keep a line on the graph after beginning to fiddle with a new one, and one that allows the user to start from scratch. One last feature I decided was useful and doable for me to add was a way for the user to choose the color of the line. I decided to do this through a button panel of radio buttons of the basic colors that the 'plot' function accepts. Finally, I cleaned up the aesthetics of the GUI a little bit, and below is a screenshot of what my refreshed GUI frame looks like. Now that everything looks nice and the program has a few more useful functions, it is time to actually program MATLAB to make the GUI work. My first step was simply to coordinate all the slider bars with their corresponding edit text boxes so they would update each other. This is the same thing I had to do with the two x axis options in the old version of this, but now I have to do it for all six sliders. Also, I had to include in all of the callbacks for those twelve tools a line that executes my line-graphing function. While working on this, I also had to change the function along with the GUI script because the function needs to be looking for the right handles, etc. I ran into a few vexing problems as I went along. My first problem was that I had some problem with the 'set' command when I was using it in the script and it turns out I was accidentally grabbing the 'String' property from the slider instead of its 'Value' property. After spending a decent time locating that silly error, I then encountered a problem with two of the sliders. The x and y radius sliders I realized should not be able to have negative values, given that I calculate the xmin and xmax by subtracting and adding from the radius to the center. So, I adjusted the minimum value to 0, and then realized even 0 could not be included. My compromise between making 1 the lowest possible value for the slider or getting rid of the idea entirely, I set the minimum values for the radius sliders to 10^-100. Once I got past these and actually began testing my improvements, I felt the world was playing a trick on me because I once again was stonewalled. Nothing was appearing on the graph, but the axes would change when I changed the x and y radius and center. I concluded it had to be something wrong with my 'plot' command in the function. What in fact ended up being the issue, after some scrutiny by me, was that I put a division sign where I needed a multiplication sign when determining 'n' for the x linspace, so there may have been one point graphed somewhere each time but there was surely nothing I could see. Once I swapped that out, I got a fairly nice result, shown below. (I apologize that the "Green" button is selected even though the line is graphed in blue, I just hadn't even paid attention to the colors until I saw this video) http://screencast.com/t/ng7SY7d2BS7H (When we talk, I might need a brief update on uploading videos to the wiki. I've been having trouble)

Also, here is a snapshot of my current function that is often called on to plot the line in the GUI

That is it for this week. Next week I will work on the color changing as well as keeping old lines and clearing the graph. There are two things I would like to note (in case I forget) that the straight line applet you showed me brought into light: displaying the x=0 and y=0 axes in bold lines at all times, and giving the user the ability to adjust the limits of the sliders via a popup dialog box (this one I feel would be good for bringing Chapter 12 into my programming).