Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %Written by: Taylor Poon, ID: 30750539
- %Created: 18/09/19
- %yeasty bacteria growth rate that produces an antibiotic
- clear all; close all; clc;
- %root finding equation
- %anonymous function for yeasty boi equation
- g = @ (c) 2.*c./(4+0.8.*c+c.^2+0.2.*c.^3);
- dg = @ (c) 10*(20 - 5*c.^2 - 2*c.^3)./((c + 5).^2.*(c.^2+4).^2);
- %determine value of c where growht is maximum using false position method
- cl = 0; %change bounds as they are inappropriate?
- cu = 5;
- precision = 1e-4;
- [root,iter] = falseposition(dg, cl, cu, precision);
- %plots
- c = linspace(0,10);
- %plot: g against c
- plot(c, g(c))
- title('Yeasty Boi Function');
- xlabel('food concentration (mg/L)');
- ylabel('specific growth rate (day^-1)');
- %plot: g' against c
- hold on
- plot (c, dg(c), 'k')
- %plot: vertical line
- xline(root, 'r');
- legend('g against c', 'dg against c', 'vertical line at solution')
- %print statement
- 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