GEOL 380 & 705 Lab 1 – Practice Graphics with Matlab

15 downloads 67 Views 18KB Size Report
GEOL 380 & 705. Lab 1 – Practice Graphics with Matlab. Description: This mini- lab is designed to introduce students to the basic plotting routines offered by ...
GEOL 380 & 705 Lab 1 – Practice Graphics with Matlab Description: This mini-lab is designed to introduce students to the basic plotting routines offered by Matlab. At the end of this exercise students will be expected to understand the basic syntax for loading data, specifying variables and generating x-y plots. Students should also realize the benefits of creating and using ‘.m’ files, and setting pathways within the Matlab workspace. Part I – Warm up! Instructions: 1. Within your home directory create a folder called GEOL380 or PGEOG705. Then create a subfolder named PlottingBasics. 2. If you are feeling adventurous review the wave data download pdf. Follow instructions to obtain your own data set from one of the coastal buoy stations and save to the PlottingBasics subfolder. 3. Open Matlab Development Environment and set the path to your PlottingBasics subfolder. 4. Download and review example data (1997.txt, 1998.txt) and script (wave_ex1.m) from website. 5. With the development environment create a .m file 6. Within your .m file: load the buoy data. 7. Specify variables to be plotted (begin with wave height, period, and direction). 8. Write the syntax to create a figure with three plots (1. wave height, 2. period, and 3. direction). Save your .m file and run it. To run a .m file with the matlab environment type the name of the .m file (leave off the extension). So to run the wave_ex1.m script, you would type ‘wave_ex1’. What happens and what do the plots look like? 9. Faulty buoy measurements appear as 99’s, so you must remove/replace them. Use the find command to replace the 99’s with ‘nan’s. Matlab will leave blanks where nans are present. Review wave_ex1.m for details. 10. By default matlab will plot the variables against the row number. To plot the data against the correct date use the datenum and datetick functions within matlab. Review wave_ex1.m for details. You must specify the month, day and year etc. 11. Select a subsample of the buoy data. To do this specify the start and end date you are interested in and search the data to extract only those values that fall within the limits (Review wave_ex1.m for details). 12. Practice saving your figures (see wave_ex1.m)

Part II – Ready to work! Now that you have reproduced the wave example, continue plotting other variables including Pressure, Temperature, and Wind (You will need magnitude and direction).

1. Specify all the additional variables you might want to use in this data file. 2. Create (new) similar figures showing the annual variations of 1. Pressure, 2. Air Temperature, 3. Water Temperature, 4. Dew Point and 5. Wind Magnitude. Make sure this figure does not erase the previous figure. You may not have measurements of each of these variables, the basic idea is to explore your data. 3. Begin by creating a new figure with pressure plotted against temperature. Instead of using a line, plot the data as red points. These kinds of plots are commonly referred to as ‘scatter plots’. Make sure you label the axes, and title. 4. Similarly explore your data by plotting, for example: (a) Air Temperature vs Water temperature (b) Water Temperature vs Pressure (c) Wave Height vs Air Temperature (d) Wave Height vs Pressure and so on. In general, you might use the following question to guide you as you explore your data: Can you find “visual” correlations between or/and among the variables provided in this data set. Try using other functions in Matlab to help analyze your record. For example max(H) for largest wave height or min(P) for minimum pressure. ** Write a short paragraph about your plots in your lab report. Use the guide provided on the webpage. **