Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. % Curve Fit Example Problem
  2. format compact
  3. clc
  4. % Data Set at 70 deg C
  5. time1 = [0 1 3]; % x-variable
  6. PD1 = [5.06 4.00 2.75]; % y-variable
  7.  
  8. % Curve fit polynomial fit command: polyfot(x,y,order number)
  9. coefficients1 = polyfit(time1,PD1,1); %b=slope=coefficients1(1), a=intercept
  10. D70=-1/coefficients1(1);
  11.  
  12. %Compare data vs model values
  13. time_values1=linspace(0,3,100); % 100 equally spaced points from 0 to 3
  14. PD_Model1=polyval(coefficients1, time_values1); %model calculated values
  15.  
  16. plot(time1, PD1, '*', time_values1, PD_Model1, '-k')
  17. xlabel('Time in Minutes')
  18. ylabel('Population density in CFU/mL')
  19. title('Comparison of Measured and Predicted E.coli Values in Activation at 70 C')
  20. grid on %on/off switch (off default)
  21. box on
  22. %-----------------------------------------------------------------------
  23. % plotting next data set in a new figure window
  24.  
  25. figure(2)
  26. %Data set at 60 Deg C
  27. time2=[0 1 3 6 10 15]; %x-variable
  28. PD2=[7.35 7.23 7.1 6.9 5.51 4.36]; %y-variable
  29. coefficients2=polyfit(time2,PD2,1); %b=slope=coefficients2(1), a=intercept
  30.  
  31. %Compare data vs model values
  32. time_values2=linspace(0,15,100); % 100 equally spaced points from 0 to 15
  33. PD_Model2=polyval(coefficients2, time_values2); %model calculated values
  34.  
  35. plot(time2,PD2,'*',time_values2,PD_Model2,'-k')
  36. xlabel('Time in Minutes')
  37. ylabel('Population density in CFU/mL')
  38. title('Comparison of Measured and Predicted E.coli Values in Activation at 60 C')
  39. grid on
  40. box on
  41.  
  42. figure(3)
  43. %Data set at 50 Deg C
  44. time3 = [0 1 3 6 10 15]; %x
  45. PD3 = [7.52,7.45,7.42,7.35,7.14,6.95]; %y
  46.  
  47. coefficients3=polyfit(time3,PD3,1); %b=slope=coefficients2(1), a=intercept
  48.  
  49. %Compare data vs model values
  50. time_values3=linspace(0,15,100); %100 equally spaced points from 0 to 15
  51. PD_Model3=polyval(coefficients3,time_values3); %model calculated values
  52.  
  53. plot(time3,PD3,'*',time_values3,PD_Model3,'-k')
  54. xlabel('Time in Minutes')
  55. ylabel('Population density in CFU/mL')
  56. title('Comparison of Measured and Predicted E.coli Values in Activation at 50 C')
  57. grid on
  58. box on
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement