Monday, October 5, 2015

MATLAB Day 5

Graphing By Plots


   We go back to the idea of plotting on MATLAB. We can create a variable and make it into an array and create a second variable and make it into an array. Using the plot function, we can plot a graph based on the arrays. One condition is that the arrays have to be the same size. The plot command plots the x-axis first, then the y-axis. Once we plot the graph, we can add some details. We can use the title command to give the graph a title and the xlabel function to label the x-axis. The ylabel function works the same way.


   We establish an array of angles so that we can graph the functions of sine and cosine with respect to the angles of the array. This introduces the subplot feature that allows us to look at two graphs, simultaneously, on the same window. This is a good feature for comparison purposes.


   The next feature for plotting is the hold on/off command. Selecting to hold on during plotting allows us to plot a second graph, a third, a forth, and so on, on the same graph, until we select the hold off command.


   We can also alter the graph by altering the point designs, the line design, and color of the line. We make these alterations within the plot command.



   In the next problem, we look at saturation vapor pressure. The relationship between the pressure and the temperature is given by a logarithmic. On our white boards, we refined the equation to solve for the saturation pressure, given the other pieces of information.


   We create an array of temperature values in kelvin for the problem on the whiteboard.


   More values are created in variables. We, then, use the given values to find the saturation pressure using the equation derived on the whiteboard. Since we are working with some arrays of numbers, we have to remember to account for the dot multiplication. For the amount of temperatures there are, the result displays the saturation pressures for every temperature.


   After all of the values for saturation pressure have been calculated, we plot the graph pressure vs. temperature. The graph correctly shows us an exponential change as the temperature increases.


   The next problem involves a standard projectile motion problem. The projectile in this problem shoots at an angle on a level surface and lands on the same height. Using the x-component and the y-component, we manipulate the kinematics equations t solve for the range a projectile travels.


   We start the problem on the whiteboard by giving an initial velocity of value 100. We are to create a simple program that calculates the range an object travels at angles launched from 0 to 45 degrees.


   Once the givens have been established, we create the equation to solve for the range a projectile travels at different angles launched. Again, we have to make sure that we account for the arrays that are in the equation.


   We draw the graphical representation of the values we calculated. As the angle increases, a parabolic behavior representing the distance traveled is displayed. The parabolic behavior occurs due to the flight time. We maximize our distance when we attain an angle of 45 degrees, which shows in our graph.


   The ability to do polar graphs is also available in MATLAB. The polar function in MATLAB is reliant on the radial distance, as well as the angular distance, which is how polar is traditionally done. We are able to graph polar graphs seen in calculus classes. To produce smooth curves, we need a large amount of points and radii so that we can graph smooth curves.


   We can make some interesting designs by manipulating the amount of radii and the angle plotted. The less points, the more straight lines that will form when plotting. We can make hearts, flowers, an infinity symbol creating two flower pedals and stars.


   Lastly, we go over some unique plotting abilities in MATLAB. We can plot using the semilog command, which allows MATLAB to find logarithmics of negative numbers and zero, omit these values, and plots around them. This is useful for avoiding errors.

Summary:
   A lot of graphical abilities were defined. We discussed ways to plot many graphs on one window. We also discussed ways to plot multiple lines on the same graph. What we can also do is plot different graphs on different windows. This function is the figure function. We just type Figure(#) where we number the window. We go over some physics problems and plotted the solution. We can also customize the graphs by changing the line color, the points on the line, and the line structure. We finished of by going over the polar graphing and the logarithmic graphing.

No comments:

Post a Comment