SHARE
TWEET

Computing Assignment 2 Idzan

a guest Apr 26th, 2019 119 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %%Question 2
  2. H_conc=logspace(-3,-1,10);
  3. pH=-log10(H_conc);
  4. pHtable = table(H_conc.', pH.','VariableNames',{'H_Conc','pH'})
  5.  
  6. %%Question 3
  7. Q = 8000;
  8. R = 1.987;
  9. k0 = 1200;
  10. T = linspace(100,500,50);
  11. k = k0*exp(-Q./(R*T));
  12. Arrhenius_table=table(T.',k.','VariableNames',{'T','k'})
  13.  
  14. %%Question 4
  15. format short g
  16.  
  17. thermocouple = [84.3 90.0 86.7
  18. 86.4 89.5 87.6
  19. 85.2 88.6 88.3
  20. 87.1 88.9 85.3
  21. 83.5 88.9 80.3
  22. 84.8 90.4 82.4
  23. 85.0 89.3 83.4
  24. 85.3 89.5 85.4
  25. 85.3 88.9 86.3
  26. 85.2 89.1 85.3
  27. 82.3 89.5 89.0
  28. 84.7 89.4 87.3
  29. 83.6 89.8 87.2]
  30.  
  31. max_thermocouple = max(thermocouple);
  32. max_thermocouple1 = max_thermocouple(1)
  33. max_thermocouple2 = max_thermocouple(2)
  34. max_thermocouple3 = max_thermocouple(3)
  35.  
  36. %%Question 5
  37. clear;clc
  38. t = 100:100:1000;
  39. p = 100:100:1000;
  40. R = 0.2870;
  41. [T,P]=meshgrid(t,p);
  42. v=(R*T)./P
  43.  
  44. %%Question 6
  45. clear;clc
  46. Hv = 2.453 * 10^6;
  47. Rair = 461;
  48. Tf = -60:10:120;
  49. Tk = (Tf-32)*(5/9) + 273.15 %Conversion from Fahrenheit to Kelvin
  50. po = 6.11*exp((Hv/Rair)*((1/273)-(1./Tk)));
  51. Table6=table(Tf.',po.','VariableNames',{'T_K','po_mbar'})
  52. plot(po,Tf)
  53. title('Temperature vs Saturation Vapor Pressures');
  54. xlabel('po, mbar')
  55. ylabel('T, °F')
  56.  
  57. %%Question 7
  58. Q = 1000;
  59. k0 = 10;
  60. R = 8.314;
  61. T = 300:1000;
  62. k = k0*exp(-Q./(R*T));
  63. lgk = log10(k);
  64. Tinv = 1./T;
  65.  
  66.     subplot(2,1,1)
  67. plot(T,k)
  68. title('k vs T')
  69. xlabel('T')
  70. ylabel('k')
  71.  
  72.     subplot(2,1,2)
  73. plot(lgk,Tinv)
  74. title('lgk vs 1/T')
  75. xlabel('1/T')
  76. ylabel('lgk')
  77.  
  78. %%Question 8
  79. mass = 1:1:10;
  80. mr = [78.115 46.07 102.3];
  81. nmoles(mass,mr)
  82.  
  83. %%Question 9
  84. n = 1:1:10;
  85. mr = [78.115 46.07 102.3];
  86. mass(n,mr)
  87.  
  88. %%Question 11
  89. clear;clc
  90. a = 28.90;
  91. b = 0.1967 * 10^-2;
  92. c = 0.4802 * 10^-5;
  93. d = -1.966 * 10^-9;
  94. T1 = 300;
  95. T2 = 300;   %Initial guess
  96. h = a*(T2-T1) + 0.5*b*(T2^2-T1^2)+(c/3)*(T2^3-T1^3)+0.25*d*(T2^4-T1^4);
  97. while h<8900    %Iterative loop
  98.     T2 = T2 + 0.01;
  99.     h = a*(T2-T1) + 0.5*b*(T2^2-T1^2)+(c/3)*(T2^3-T1^3)+0.25*d*(T2^4-T1^4);
  100. end
  101.  
  102. T2
  103.  
  104. %%nmoles
  105. %Needed to save as separate file, nmoles.m to answer Question 8
  106. function output = nmoles(mass,mr)
  107.  
  108. [MASS,MR]=meshgrid(mass,mr);
  109.  
  110. output = (MASS./MR)';
  111.  
  112. %%mass
  113. %Needed to save as separate file, mass.m to answer Question 9
  114. function output = mass(moles,mr)
  115.  
  116. [MOLES,MR]=meshgrid(moles,mr);
  117.  
  118. output = (MOLES.*MR)';
  119.  
  120. %%heat
  121. %Needed to save as separate file, heat.m to answer Question 10
  122. function output = heat(mass)
  123. m = 1;
  124. Cp = 1;
  125. output = mass*m*Cp;
  126.  
  127. %%cal_to_j
  128. %Needed to save as separate file, cal_to_j.m to answer Question 10
  129. function output = cal_to_j(cal)
  130. output = 4.2*cal;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top