Below we show how to execute the MatLab function fminsearch with a user defined

# Below we show how to execute the matlab function

• 11

This preview shows page 3 - 6 out of 11 pages.

by []). Below we show how to execute the MatLab function fminsearch with a user defined function sumsq vonBert , including an initial guess and the data sets. 1 [ p1 , J , f l a g ] = fminsearch ( @sumsq vonBert , [ 1 0 0 , 0 . 1 ] , [ ] , tdfish , l d f i s h ) MatLab returns the best fitting parameter values in the vector p 1 (which could be used in another iteration if one is uncertain of convergence), the least sum of square errors, J , and a variable flag , which is 1 if MatLab thinks fminsearch has converged and 0 if it failed to converge. For our Subscribe to view the full document.

particular problem, MatLab returns the results p 1 = [92 . 401 , 0 . 14553], J = 1 , 107 . 3, and flag = 1, so the best fitting parameters are L * = 92 . 401 and b = 0 . 14553 and our best model for the length of Lake Trout as it ages is L ( t ) = 92 . 401 1 - e - 0 . 14553 t . A MatLab script file is developed to graph this best fitting model and the data. This best fitting model is shown with the data in the graph below. The script, vonBert plot.m , is available from the Lecture notes (including initial clear and final text and output controls, which are omitted here for clarity). 1 2 c l e a r % Clear previous d e f i n i t i o n s 3 f i g u r e (1) % Assign f i g u r e number 4 c l f % Clear previous f i g u r e s 5 hold o f f % Start with f r e s h graph 6 7 mytitle = ’ Length of Lake Trout ’ ; % T i t l e 8 xlab = ’Age ( Years ) ’ ; % X - l a b e l 9 ylab = ’ Length (cm) ’ ; % Y - l a b e l 10 11 load ( ’ f i s h d a t ’ ) ; % Provide vectors of Lake Trout data 12 13 tt = l i n s p a c e (0 ,20 ,500) ; % t domain of function 14 Lt = 92.404 * (1 - exp ( - 0.14553 * tt ) ) ; % Function f o r von Bertalanffy 15 16 plot ( tt , Lt , ’b - , ’ LineWidth ’ , 1 . 5 ) ; % Plot model 17 hold on % Plots Multiple graphs 18 plot ( tdfish , l d f i s h , ’ bo ’ , ’ LineWidth ’ , 1 . 5 ) ; % Plot data with c i r c l e s 19 20 grid % Adds Gridlines 21 22 xlim ( [ 0 2 0 ] ) ; % Defines l i m i t s of graph 23 ylim ( [ 0 100]) ; 24 25 f o n t l a b s = ’ Times New Roman ’ ; % Font type used in l a b e l s 26 x l a b e l ( xlab , ’ FontSize ’ ,14 , ’FontName ’ , fontlabs , ’ i n t e r p r e t e r ’ , ’ latex ’ ) ; 27 % x - Label s i z e and font 28 y l a b e l ( ylab , ’ FontSize ’ ,14 , ’FontName ’ , fontlabs , ’ i n t e r p r e t e r ’ , ’ latex ’ ) ; 29 % y - Label s i z e and font 30 t i t l e ( mytitle , ’ FontSize ’ ,16 , ’FontName ’ , ’ Times New Roman ’ , ’ i n t e r p r e t e r ’ , ’ latex ’ ) ; 31 % T i t l e s i z e / font 32 set ( gca , ’ FontSize ’ ,12) ; % Axis t i c k font s i z e 33 34 print - depsc vonBert . eps % Create f i g u r e as EPS f i l e 35 %print - djpeg vonBert . jpg % Create f i g u r e as JPEG f i l e The graph of the von Bertalanffy model with the relevant data is below. 0 2 4 6 8 10 12 14 16 18 20 0 10 20 30 40 50 60 70 80 90 100 Age (Years) Length (cm) Length of Lake Trout Relation Between Weight and Length The next step in the modeling for this problem is to find a functional relationship between the weight and the length of the Lake Trout. This is known as Allometric modeling or a Power Law relationship. Specifically, we examine a relationship of the form W = kL a . Subscribe to view the full document. • Fall '08
• staff

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern