This document contains code for a MATLAB function that calculates the exact and approximate values of Q as a function of temperature T. It finds the exact Q values using a while loop and sums exponential terms. It then plots the exact and approximate Q vs T curves and finds the temperature where they intersect within 5%.
This document contains code for a MATLAB function that calculates the exact and approximate values of Q as a function of temperature T. It finds the exact Q values using a while loop and sums exponential terms. It then plots the exact and approximate Q vs T curves and finds the temperature where they intersect within 5%.
Qapprox=0.107*T; end function [QatT] = exactperT(T) QatT=0; J=0; QatTi=1; while QatTi>0.0000000000000000001 QatTi=(2*J+1)*exp(-9.347*(1/T)*(J*(J+1))); QatT=QatT+QatTi; J=J+1; end end %-------Finding Exact Values------Temperatures=1:1:100; Qvalues=1:length(Temperatures); for i=1:length(Temperatures) T=Temperatures(i); Qvalues(i)=exactperT(T); end %----Finding Approximate Values---ApproxQValues=0.107.*Temperatures; %-----Plotting-----hold on plot(Temperatures,Qvalues,'LineWidth',1,'Color','black') plot(Temperatures,ApproxQValues,'LineWidth',1) %----Finding the Temperature----for j=1:length(Temperatures) if abs(Qvalues(j)-ApproxQValues(j))/Qvalues(j) <= 0.05 TIntersect=Temperatures(j); break end end TIntersect