% Modified from (Lynch, 2004): % Chapter 7 - Differential Equations. % Program_7b - Solution curves, initial value problem. % Copyright Birkhauser 2004. Stephen Lynch. % Solve the differential equation and plot 2 solution curves. clear deqn1=inline('P(1)*(100-P(1))/1000','t','P'); % Define inline function [t,P1]=ode45(deqn1,[0 100],50); % Integrate differential equation (x_0 = 50) [t1,P2]=ode45(deqn1,[0 100],150); % Integrate differential equation (x_0 = 150) % ----- render x vs t graph ----------- fsize=15; % set font size for graph hold on % retain the current plot to add more than 1 function plot(t,P1(:,1), 'r') % plot P(1) vs t, color red plot(t1,P2(:,1), 'b') % plot P(1) vs t, color red hold off % release hold on current plot axis([0 100 0 200]) % set axis set(gca,'xtick',[0:20:100],'FontSize',fsize) % Set (Current axes handle) ticks, and fonts set(gca,'ytick',[0:50:200],'FontSize',fsize) % Set (Current axes handle) ticks, and fonts xlabel('t','FontSize',fsize) % Set x-axis label ylabel('P','FontSize',fsize) % Set x-axis label % End of Program_7b.