Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. %Written by: Taylor Poon, ID: 30750539
  2. %Created: 18/09/19
  3. %yeasty bacteria growth rate that produces an antibiotic
  4. clear all; close all; clc;
  5.  
  6. %root finding equation
  7. %anonymous function for yeasty boi equation
  8. g = @ (c) 2.*c./(4+0.8.*c+c.^2+0.2.*c.^3);
  9. dg = @ (c) 10*(20 - 5*c.^2 - 2*c.^3)./((c + 5).^2.*(c.^2+4).^2);
  10.  
  11. %determine value of c where growht is maximum using false position method
  12. cl = 0; %change bounds as they are inappropriate?
  13. cu = 5;
  14. precision = 1e-4;
  15. [root,iter] = falseposition(dg, cl, cu, precision);
  16.  
  17. %plots
  18. c = linspace(0,10);
  19. %plot: g against c
  20. plot(c, g(c))
  21. title('Yeasty Boi Function');
  22. xlabel('food concentration (mg/L)');
  23. ylabel('specific growth rate (day^-1)');
  24. %plot: g' against c
  25. hold on
  26. plot (c, dg(c), 'k')
  27.  
  28. %plot: vertical line
  29. xline(root, 'r');
  30. legend('g against c', 'dg against c', 'vertical line at solution')
  31.  
  32. %print statement
  33. fprintf('The value of the concentration when the growth is a maximum is %f, and the numer of iterations using the false position method was %0.f.', root, iter);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement