# gnuplot script # Biochem 721.3 Foster 05/05 # for problem 7.8 # data are time (s), conc (mM) set title "Problem 7.8" unset label set fit errorvariables set autoscale a=1; b=1 set ylabel 'Conc (mM)' set xlabel 'Time (s)' set xrange [0:22] f(x) = a*exp(-x*b) plot 'p7_8.txt' ps 3 pt 4 fit f(x) 'p7_8.txt' via a,b set label "conc. = A * exp( -time*rate)" at graph 0.1,0.8 set label "A = %.2f", a, "+/- %.2g", a_err at graph 0.6,0.2 set label "rate = %.2f b", b, "+/- %.2g", b_err at graph 0.6,0.25 replot f(x) print 'Check plot for fitting accuracy print "" pause -1 'Now calculate the residuals; press return' set ylabel 'Conc. (mM); residuals' plot 'p7_8.txt' using 1:($2-f($1)) wi boxes, 0 pause -1 'If instead we fit to 2nd order (1/c) ... (return)' plot 'p7_8.txt' ps 3 pt 4 y(x) = 1/(b*x + 1/a) #fit y(x) 'p7_8.txt' using 1:(1/$2) via a,b fit y(x) 'p7_8.txt' via a,b unset label set label "conc. = 1/(rate*time + 1/A)" at graph 0.1,0.8 set label "A = %.2f", a, "+/- %.2g", a_err at graph 0.6,0.2 set label "rate = %.2f", b, "+/- %.2g", b_err at graph 0.6,0.25 replot y(x) pause -1 'Inspect plot, then check residuals (rtrn)' plot 'p7_8.txt' using 1:($2-y($1)) w boxes, 0 print 'Now residuals are RANDOM!'