User Tools

Site Tools


gibson:teaching:fall-2014:math445:lecture6-diary

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
Last revision Both sides next revision
gibson:teaching:fall-2014:math445:lecture6-diary [2014/09/18 11:47]
gibson [Math 445 lecture 6: logical array operations and log-linear relations]
gibson:teaching:fall-2014:math445:lecture6-diary [2014/09/18 12:19]
gibson [Graphical data analysis of log-linear relations]
Line 275: Line 275:
  
 % Ok, let's move on the the next data file and try to figure out its y = f(x) relation. ​ % Ok, let's move on the the next data file and try to figure out its y = f(x) relation. ​
-D = load('​data3.asc'​);​ +>> ​D = load('​data3.asc'​);​ 
-x= D(:,1); +>> xdata = D(:,1); 
-y=D(:,2); +>> ydata = D(:,2); 
-plot(x,y,'​mo-'​) +>> ​plot(xdataydata,'​mo-'​); xlabel('​x'​);​ ylabel('​y'​);​ grid on 
-% looks exponential,​ so graph y logarithmically +</​code>​ 
-semilogy(x,​y,'​mo-'​)+ 
 +{{ :​gibson:​teaching:​fall-2014:​math445:​logplot0.png?​nolink&​400 |}} 
 + 
 +<code matlab> 
 +That looks exponential,​ so graph y logarithmically 
 +>> ​semilogy(xdata, ydata, '​mo-'​);​ xlabel('​x'); ylabel('​y'​);​ grid on 
 +</​code>​ 
 + 
 +{{ :​gibson:​teaching:​fall-2014:​math445:​logplot1.png?​nolink&​400 |}} 
 + 
 +<code matlab>​ 
 +% Great! It's a straight line with y graphed logatithmicallyso the relation is 
 +% of the form  
 +%   ​log10 ​= m x + b,   or equivalently 
 +%         y = 10^(mx+b), or equivalently 
 +%         y = c 10^(mx) 
 +% for some constants m and c. let's take rough guesses, judging from the plot. 
 +
 +% m is the slope in log10 y versus x. log10 y drops from 2 at x=10 to about 1 at x=20. 
 +% So m looks to be about -1/10, (rise of -1 over run of 10). You can get the constant c 
 +% by estimating the value of y at x=0. That looks to be about c=400. So let's give 
 +% y = 400 10^(-0.1 x) a try. 
 + 
 +>> x = linspace(-20,​ 50, 10); 
 +>> semilogy(xdata,​ ydata,'​mo-'​, x, 400*10.^(-0.1*x)); xlabel('​x'​);​ ylabel('​y'​);​ grid on 
 +</​code>​ 
 + 
 +{{ :​gibson:​teaching:​fall-2014:​math445:​logplot2.png?​nolink&​400 |}} 
 + 
 +<code matlab>​ 
 +% Not too shabby. But the slope is a little too negative and y is too low at x=0.  
 +% A few iterations of adjusting the constants gives 
 + 
 +>> semilogy(xdata,​ ydata,'​mo-',​ x, 700*10.^(-0.085*x));​ xlabel('​x'​);​ ylabel('​y'​);​ grid on 
 +</​code>​ 
 + 
 +{{ :​gibson:​teaching:​fall-2014:​math445:​logplot3.png?​nolink&​400 |}} 
 + 
 +<code matlab>​ 
 +% 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>​
gibson/teaching/fall-2014/math445/lecture6-diary.txt · Last modified: 2014/09/18 12:21 by gibson