User Tools

Site Tools


gibson:teaching:spring-2016:math445:lab3

====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gibson:teaching:spring-2016:math445:lab3 [2016/02/03 13:03]
gibson
gibson:teaching:spring-2016:math445:lab3 [2016/02/11 08:29] (current)
gibson
Line 1: Line 1:
-====== Math 445 lab 3: scripts, ​plotting, and publishing ​======+====== Math 445 lab 3: scripts, ​log-linear relations ​======
  
 Write a single Matlab script file that solves the following problems, and use the [[http://​www.mathworks.com/​help/​matlab/​matlab_prog/​publishing-matlab-code.html | Matlab ''​publish''​]] function to create a nice-looking PDF of your code and graphs to turn in. Be sure to label each problem with comments like ''<​nowiki>​ %% Problem 1%% </​nowiki>''​ so that the problems are separated and labeled in the PDF.  Write a single Matlab script file that solves the following problems, and use the [[http://​www.mathworks.com/​help/​matlab/​matlab_prog/​publishing-matlab-code.html | Matlab ''​publish''​]] function to create a nice-looking PDF of your code and graphs to turn in. Be sure to label each problem with comments like ''<​nowiki>​ %% Problem 1%% </​nowiki>''​ so that the problems are separated and labeled in the PDF. 
Line 9: Line 9:
 **Problem 3:** Make a plot of $y(x) = 0.3 \log x + 2$ over the range $1 \leq x \leq 10^5$ using a dot-dashed cyan line. Chose an appropriate plotting function that best displays the functional relationship between $x$ and $y$. For this plot, it's best to create the ''​x''​ vector with ''​logspace''​ rather than ''​linspace'';​ e.g. ''​x = logspace(0,​5,​20)''​ will set ''​x''​ to 20 points between $1 = 10^0$ and $10^5$ which are uniformly spaced on a logarithmic plot. Label the axes, set the $y$ range of the plot to $2 \leq y \leq 6$, and place a coordinate grid within the plot. Title the plot as in previous problems. **Problem 3:** Make a plot of $y(x) = 0.3 \log x + 2$ over the range $1 \leq x \leq 10^5$ using a dot-dashed cyan line. Chose an appropriate plotting function that best displays the functional relationship between $x$ and $y$. For this plot, it's best to create the ''​x''​ vector with ''​logspace''​ rather than ''​linspace'';​ e.g. ''​x = logspace(0,​5,​20)''​ will set ''​x''​ to 20 points between $1 = 10^0$ and $10^5$ which are uniformly spaced on a logarithmic plot. Label the axes, set the $y$ range of the plot to $2 \leq y \leq 6$, and place a coordinate grid within the plot. Title the plot as in previous problems.
  
-**Problem 4:** Make a plot of $y(x) = 10 x^{-3}$ over the range $10 \leq x \leq 10^4$ using a solid green line. Chose an appropriate plotting function that best displays the functional relationship between $x$ and $y$. Use the ''​logspace''​ function for ''​x''​ as in problem 3. Label the axes, set the $x$ range of the plot to $0 \leq x \leq 10^5$, and place a coordinate grid within the plot. Title the plot as in previous problems.+**Problem 4:** Make a plot of $y(x) = 10 x^{-3}$ over the range $10 \leq x \leq 10^4$ using a solid green line. Chose an appropriate plotting function that best displays the functional relationship between $x$ and $y$. Use the ''​logspace''​ function for ''​x''​ as in problem 3. Label the axes, set the $x$ range of the plot to $10^0 \leq x \leq 10^5$, and place a coordinate grid within the plot. Title the plot as in previous problems.
  
-**Problems ​5,6,7:** For these problems you will deduce the functional relationship between variables in data sets using graphical analysis. The data sets are given as // N x 2// matrices with //x// as the first column and //y// as the second. For each data set, you will find a function //y(x)// that fits the data, using the following steps:+**Instructions for problems ​5,6,7:** For these problems you will deduce the functional relationship between variables in data sets using graphical analysis. The data sets are given as // N x 2// matrices with //x// as the first column and //y// as the second. For each data set, you will find a function //y(x)// that fits the data, using the following steps:
  
   - Download or cut & paste the data set to a text file with an appropriate name, e.g. ''​earthquake_magnitude.asc''​ for problem 1.   - Download or cut & paste the data set to a text file with an appropriate name, e.g. ''​earthquake_magnitude.asc''​ for problem 1.
Line 27: Line 27:
   * appropriate labels for each axis and a title   * appropriate labels for each axis and a title
  
-and specify the function form of +and provide an explicit formula for $y(x)$. ​
  
  
  
-**Problem ​2: The distribution of earthquake magnitudes, by Moment Magnitude scale.** ​+**Problem ​5: The distribution of earthquake magnitudes, by Moment Magnitude scale.** ​
 Big earthquakes are rare, and little earthquakes are frequent. In fact, there is a  Big earthquakes are rare, and little earthquakes are frequent. In fact, there is a 
 very clean empirical law that governs how many earthquakes of a given magnitude ​ very clean empirical law that governs how many earthquakes of a given magnitude ​
Line 53: Line 53:
 Using Matlab plotting commands, deduce the form of the functional relationship //N(M)//. Estimate ​ the constants in the relationship by estimating the slope and the //​y//​-intercept,​ and then fine-tuning by matching the plot of your estimate against the plot of the data.  Using Matlab plotting commands, deduce the form of the functional relationship //N(M)//. Estimate ​ the constants in the relationship by estimating the slope and the //​y//​-intercept,​ and then fine-tuning by matching the plot of your estimate against the plot of the data. 
  
-**Problem ​2: The distribution of earthquake magnitudes, by energy.** The moment magnitude scale is logarithmic,​ in that an earthquake of magnitude //M+1// releases about 32 times more energy than an earthquake of magnitude //M//. The following dataset gives the number //N// of earthquakes in a given +**Problem ​6: The distribution of earthquake magnitudes, by energy.** The moment magnitude scale is logarithmic,​ in that an earthquake of magnitude //M+1// releases about 32 times more energy than an earthquake of magnitude //M//. The following dataset gives the number //N// of earthquakes in a given 
 year of energy //E// measured in Joules. ​ year of energy //E// measured in Joules. ​
 <file - earthquake_energy.asc>​ <file - earthquake_energy.asc>​
Line 64: Line 64:
 2e09 49000 2e09 49000
 6e07 365000 6e07 365000
-<1e06 2920000+1e06 2920000
 </​file>​ </​file>​
  
Line 70: Line 70:
 and fine-tune the constants in the relation, just as in problem 1. and fine-tune the constants in the relation, just as in problem 1.
  
-**Problem ​3: World population.** The following data set provides the human population //P// of the earth at a given time //t//, measured in years A.D.+**Problem ​7: World population.** The following data set provides the human population //P// of the earth at a given time //t//, measured in years A.D.
  
 <file - world_population.asc>​ <file - world_population.asc>​
gibson/teaching/spring-2016/math445/lab3.1454533412.txt.gz ยท Last modified: 2016/02/03 13:03 by gibson