Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Curve Fit Example Problem
- format compact
- clc
- % Data Set at 70 deg C
- time1 = [0 1 3]; % x-variable
- PD1 = [5.06 4.00 2.75]; % y-variable
- % Curve fit polynomial fit command: polyfot(x,y,order number)
- coefficients1 = polyfit(time1,PD1,1); %b=slope=coefficients1(1), a=intercept
- D70=-1/coefficients1(1);
- %Compare data vs model values
- time_values1=linspace(0,3,100); % 100 equally spaced points from 0 to 3
- PD_Model1=polyval(coefficients1, time_values1); %model calculated values
- plot(time1, PD1, '*', time_values1, PD_Model1, '-k')
- xlabel('Time in Minutes')
- ylabel('Population density in CFU/mL')
- title('Comparison of Measured and Predicted E.coli Values in Activation at 70 C')
- grid on %on/off switch (off default)
- box on
- %-----------------------------------------------------------------------
- % plotting next data set in a new figure window
- figure(2)
- %Data set at 60 Deg C
- time2=[0 1 3 6 10 15]; %x-variable
- PD2=[7.35 7.23 7.1 6.9 5.51 4.36]; %y-variable
- coefficients2=polyfit(time2,PD2,1); %b=slope=coefficients2(1), a=intercept
- %Compare data vs model values
- time_values2=linspace(0,15,100); % 100 equally spaced points from 0 to 15
- PD_Model2=polyval(coefficients2, time_values2); %model calculated values
- plot(time2,PD2,'*',time_values2,PD_Model2,'-k')
- xlabel('Time in Minutes')
- ylabel('Population density in CFU/mL')
- title('Comparison of Measured and Predicted E.coli Values in Activation at 60 C')
- grid on
- box on
- figure(3)
- %Data set at 50 Deg C
- time3 = [0 1 3 6 10 15]; %x
- PD3 = [7.52,7.45,7.42,7.35,7.14,6.95]; %y
- coefficients3=polyfit(time3,PD3,1); %b=slope=coefficients2(1), a=intercept
- %Compare data vs model values
- time_values3=linspace(0,15,100); %100 equally spaced points from 0 to 15
- PD_Model3=polyval(coefficients3,time_values3); %model calculated values
- plot(time3,PD3,'*',time_values3,PD_Model3,'-k')
- xlabel('Time in Minutes')
- ylabel('Population density in CFU/mL')
- title('Comparison of Measured and Predicted E.coli Values in Activation at 50 C')
- grid on
- box on
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement