function pemodelan_mikrobia_BAL_6 clear clc global umax Nmax q0 N0 Ncoba tspan logNcoba umax=1.11675377; %jam^-1 Nmax=10^9.14; %CFU/ml y0tebak=0.120011382; N0=10^1,45; %CFU/ml Ncoba=[10^1.45;10^1.60;10^2.52;10^4.10;10^4.94;10^7.22;10^8.39;10^9.10;10^9.14]; logNcoba=log10(Ncoba) %y(1)= q %y(2)= N tspan=[0;2;4;6;8;12;16;20;24]; [solution,sse,exitflag,output]=fminsearch(@func_RMSE,y0tebak) end function RMSE=func_RMSE(y0) global umax Nmax q0 N0 Ncoba tspan logNcoba q=[y0;N0]; %y0=[X0 T0] [t y]=ode23(@func_ode,tspan,q); hasil = [t y] Nhit=y(:,2) Nhit2=[log10(Nhit)]' Nhit_inv=log10(Nhit); N02=[log10(Ncoba)]' RMSE=(sum((N02-Nhit2).^2)./length(tspan)).^0.5 % huruf dalam tanda petik kedua menyatakan betuk kurva plot(t,N02,'bo',t,Nhit2,'r-') % huruf dalam tanda petik pertama menyatakan warna kurva %mencari R2 SStot=sum((logNcoba-mean(logNcoba)).^2); SSres=sum((logNcoba-Nhit_inv).^2); R2=1-(SSres./SStot) end function dy=func_ode(t,y) global umax Nmax q0 N0 q=y(1); N=y(2); dq=umax.*y(1); dN=(y(1)./(1+y(1))).*umax.*(1-(y(2)./Nmax)).*y(2); dy=[dq;dN]; end