This differential equation is readily solved with details in the lecture notes

This differential equation is readily solved with

This preview shows page 9 - 11 out of 11 pages.

) is the amount of Hg in the fish. This differential equation is readily solved with details in the lecture notes. The resulting equation for the amount of Hg in the fish is: H ( t ) = κW * 6 b 6 bt + 18 e - bt - 9 e - 2 bt + 2 e - 3 bt - 11 . The concentration in the fish satisfies c ( t ) = H ( t ) W ( t ) . With the values of W * and b determined by our weight model, this becomes a one parameter, κ , search to fitting the data on the concentration of mercury in fish as they age. Below are the MatLab programs used to fit the data for the concentration of mercury in fish as they age. The first program computes the sum of square errors. 1 function J = sumsq Hg (p , tdata , hgdata ,w) 2 % Function computing sum of square e r r o r s f o r von Bertalanffy model 3 % p i s kappa , tdata and hgdata are f i s h data , w = [W * ,b ] 4 model = (p * w(1) /(6 * w(2) ) ) * (6 * w(2) * tdata + 18 * exp ( - w(2) * tdata ) - . . . 5 9 * exp ( - 2 * w(2) * tdata ) + 2 * exp ( - 3 * w(2) * tdata ) - 11) ; % H( t ) 6 wt = w(1) * (1 - exp ( - w(2) * tdata ) ) . ˆ 3 ; % W( t )
Image of page 9

Subscribe to view the full document.

7 ct = model ./ wt ; % c ( t ) 8 e r r o r = ct - hgdata ; 9 J = e r r o r * error ’ ; 10 end This program is used in the MatLab script with fminsearch to find the best fitting models and graph the models and the data. 1 mytitle = ’ Mercury in Lake Trout ’ ; % T i t l e 2 xlab = ’Age ( Years ) ’ ; % X - l a b e l 3 ylab = ’Hg (ppm) ’ ; % Y - l a b e l 4 5 load ( ’ f i s h d a t ’ ) ; % Provide vectors of Lake Trout data 6 7 tt = l i n s p a c e (0 ,20 ,500) ; % t domain of function 8 9 w1 = [ 6 2 9 5 . 4 , 0 . 1 4 5 5 3 ] ; 10 [ p1 , J1 , f l a g ]= fminsearch (@sumsq Hg , 0 . 1 , [ ] , tdfish , hgdfish , w1) ; 11 model1 = ( p1 * w1(1) /(6 * w1(2) ) ) * (6 * w1(2) * tt + 18 * exp ( - w1(2) * tt ) - . . . 12 9 * exp ( - 2 * w1(2) * tt ) + 2 * exp ( - 3 * w1(2) * tt ) - 11) ; 13 wt1 = w1(1) * (1 - exp ( - w1(2) * tt ) ) . ˆ 3 ; 14 ct1 = model1 ./ wt1 ; 15 w2 = [ 5 6 7 7 . 6 7 , 0 . 1 6 9 6 0 ] ; 16 [ p2 , J2 , f l a g ]= fminsearch (@sumsq Hg , 0 . 1 , [ ] , tdfish , hgdfish , w2) ; 17 model2 = ( p2 * w2(1) /(6 * w2(2) ) ) * (6 * w2(2) * tt + 18 * exp ( - w2(2) * tt ) - . . . 18 9 * exp ( - 2 * w2(2) * tt ) + 2 * exp ( - 3 * w2(2) * tt ) - 11) ; 19 wt2 = w2(1) * (1 - exp ( - w2(2) * tt ) ) . ˆ 3 ; 20 ct2 = model2 ./ wt2 ; 21 22 plot ( tt , ct1 , ’b - , ’ LineWidth ’ , 1 . 5 ) ; % Plot model cubic von Bertalanffy 23 hold on % Plots Multiple graphs 24 plot ( tt , ct2 , ’ r - , ’ LineWidth ’ , 1 . 5 ) ; % Plot model nonlinear f i t 25 plot ( tdfish , hgdfish , ’ ro ’ , ’ LineWidth ’ , 1 . 5 ) ; % Plot data with red c i r c l e s 26 27 grid % Adds Gridlines 28 legend ( { ’ Cubic von Bertalanffy ’ , ’ Nonlinear Fit ’ , ’ Data ’ } , ’ l o c a t i o n ’ , ’ Northwest ’ , FontSize ’ ,10 , ’FontName ’ , ’ Times New Roman ’ ) ; % Create legend 29 xlim ( [ 0 2 0 ] ) ; % Defines l i m i t s of graph 30 ylim ( [ 0 0 . 7 ] ) ; This MatLab script finds that using the weight model with the cubic best fitting von Bertalanffy model gives κ = 0 . 071406 with a least sum of square errors to the data of J = 0 . 17113, while the weight model with the cubic nonlinear fit model gives κ = 0 . 066953 with a least sum of square errors to the data of J = 0 . 17427. The graph is shown below with the data, and it is clear that choice of model is almost indistinguishable between these two models compared to the data.
Image of page 10
0 2 4 6 8 10 12 14 16 18 20 0 0.1 0.2 0.3 0.4 0.5 0.6 Age (Years) Hg (ppm) Mercury in Lake Trout Cubic von Bertalan ff y Nonlinear Fit Data
Image of page 11
  • Fall '08
  • staff

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes