4 An alternate way to program in MatLab is creating script files 5 The

# 4 an alternate way to program in matlab is creating

• 3

This preview shows page 2 - 3 out of 3 pages.

4. An alternate way to program in MatLab is creating script files. 5. The following script file does the first parts of Problem 18, including the best fitting von Bertalanffy equation and the allometric model along with the associated graphs of the models and data: 1 % von Bertalanffy Problem 18 2 3 c l e a r ; c l c ; 4 5 td = [1 2 3 4 5 6 7 8 9 1 0 ] ; 6 ld = [ 0 . 7 7 1.3 1.59 1.72 1.8 1.83 1.85 1.86 1.87 1 . 8 7 ] ; 7 [ p1 , J ] = fminsearch (@sum vonB , [ 1 . 8 8 , 0 . 5 ] , [ ] , td , ld ) % Find parameters and SSE 8 tt = l i n s p a c e (0 ,15 ,200) ; % Create domain f o r function on the i n t e r v a l [ 0 , 1 5 ] with 200 points 9 l l = p1 (1) * (1 - exp ( - p1 (2) * tt ) ) ; % Vector function of model 10 plot ( td , ld , ’ bo ’ ) ; % Graph data 11 hold on 12 plot ( tt , l l , ’ r - ) ; grid ; % Graph model 13 t i t l e ( ’ von Bertalanffy Model of Marlin ’ , ’ FontSize ’ ,16 , ’FontName ’ , ’ Times New Roman ’ ) ; 14 xlabel ( ’ \$t\$ ( yrs ) ’ , ’ FontSize ’ ,16 , ’ i n t e r p r e t e r ’ , ’ latex ’ ) ; 15 ylabel ( ’ Length (m) ’ , ’ FontSize ’ ,16 , ’ i n t e r p r e t e r ’ , ’ latex ’ ) ; 16 hold o f f 17 18 print - depsc marl in len gr . eps % Save as . eps f i l e 19 20 f i g u r e (102) 21 22 Ld = [1 1.11 1.16 1.21 1.28 1.38 1.47 1.53 1.68 1 . 7 7 ] ; 23 Wd = [7 12 15 19 21 31 32 34 52 6 5 ] ; 24 lnLd = log (Ld) ; % Find log of length data 25 lnWd = log (Wd) ; % Find log of weight data 26 coef = p o l y f i t ( lnLd , lnWd , 1 ) % Find power law c o e f f i c i e n t s 27 a = coef (1) ; 28 k = exp ( coef (2) ) ; 29 Ll = l i n s p a c e

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