EMEC 203-CAE II PRELab 4 – 2D Plotting SELF-GUIDED LEARNING: This topic introduces graphics and plotting in MATLAB. This provides you with an understanding of MATLAB as not only a programming language, but also as a useful tool. With it, you are able to create beautiful plots, graphs, and images that can communicate your findings to others (engineers and non-engineers) in a useful and meaningful way. Up until this point, we have been viewing our results by printing numbers to the screen. While this still may be the best way to look at results in some situations, the ability to create visual plots or graphs opens up a whole toolbox of tools that you can use throughout your engineering career. 2D Graphics – we will start with the simplest of plots: line plots. 1. Create an array (use variable name x) and fill it with 40 evenly spaced values from 0 to 2*pi. Use that array to create a line plot of the function y=cos(2*x). Copy down the code here. 2. Give the plot a title (‘Plot of Cosine’). Copy down the code here. 3. Label the x and y axis (‘x’ and ‘y’, respectively). Copy down the code here. 4. Create another array of the function, z=sin(x). Overlay the line plot of z on top of the line plot of y. Color the line of z red and increase its Linewidth to 2. Copy down the code here. 5. Change the x-axis of the plot to range from pi/2 to 3*pi/2. Copy down the code here. 6. What command do you use to open up a new figure window? Name:_________________________________ PRELab 4 – 2D Plotting EMEC 203-CAE II 7. How do you break a single figure into multiple subplots? How does the numbering work? 8. Describe at least two other 2D plotting functions available in MATLAB and show how they work.