====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
gibson:teaching:fall-2014:math445:lecture6-diary [2014/09/18 12:16] gibson [Graphical data analysis of log-linear relations] |
gibson:teaching:fall-2014:math445:lecture6-diary [2014/09/18 12:21] (current) gibson [Graphical data analysis of log-linear relations] |
||
---|---|---|---|
Line 191: | Line 191: | ||
===== Graphical data analysis of log-linear relations ===== | ===== Graphical data analysis of log-linear relations ===== | ||
- | <code matlab> | + | ==== example 1: a linear relationship ==== |
- | % ======================================================================= | + | |
- | % Ok. Let's move on the graphical data analysis | + | |
+ | <code matlab> | ||
% Load datafile 'data1.asc' into matlab with 'load' command | % Load datafile 'data1.asc' into matlab with 'load' command | ||
>> D = load('data1.asc'); | >> D = load('data1.asc'); | ||
Line 271: | Line 270: | ||
<code matlab> | <code matlab> | ||
- | % Perfect! The functional relation between y and x is y = -0.49 x + 19 | + | % Perfect! So the functional relation between y and x is y = -0.49 x + 19 |
+ | </code> | ||
+ | ==== example 2: a log-linear relationship ==== | ||
- | % Ok, let's move on the the next data file and try to figure out its y = f(x) relation. | + | <code matlab> |
+ | % Load the next data file and try to figure out its y = f(x) relation. | ||
>> D = load('data3.asc'); | >> D = load('data3.asc'); | ||
>> xdata = D(:,1); | >> xdata = D(:,1); | ||
>> ydata = D(:,2); | >> ydata = D(:,2); | ||
- | >> plot(xdata, ydata,'mo-'); grid on | + | >> plot(xdata, ydata,'mo-'); xlabel('x'); ylabel('y'); grid on |
</code> | </code> | ||
+ | |||
+ | {{ :gibson:teaching:fall-2014:math445:logplot0.png?nolink&400 |}} | ||
<code matlab> | <code matlab> | ||
Line 285: | Line 289: | ||
>> semilogy(xdata, ydata, 'mo-'); xlabel('x'); ylabel('y'); grid on | >> semilogy(xdata, ydata, 'mo-'); xlabel('x'); ylabel('y'); grid on | ||
</code> | </code> | ||
+ | |||
+ | {{ :gibson:teaching:fall-2014:math445:logplot1.png?nolink&400 |}} | ||
<code matlab> | <code matlab> | ||
Line 302: | Line 308: | ||
>> semilogy(xdata, ydata,'mo-', x, 400*10.^(-0.1*x)); xlabel('x'); ylabel('y'); grid on | >> semilogy(xdata, ydata,'mo-', x, 400*10.^(-0.1*x)); xlabel('x'); ylabel('y'); grid on | ||
</code> | </code> | ||
+ | |||
+ | {{ :gibson:teaching:fall-2014:math445:logplot2.png?nolink&400 |}} | ||
<code matlab> | <code matlab> | ||
Line 310: | Line 318: | ||
</code> | </code> | ||
+ | {{ :gibson:teaching:fall-2014:math445:logplot3.png?nolink&400 |}} | ||
<code matlab> | <code matlab> | ||
% so the functional form is y = 700 * 10^(-0.085 x). | % so the functional form is y = 700 * 10^(-0.085 x). | ||
+ | |||
+ | % Don't ask me why Matlab keeps changing the grid lines on the logarithmic plots... | ||
</code> | </code> |