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%.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
40 views2 pages
3 Problem Set 2 Problem 1
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%.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
9/15/15 11:39 AM
\\base\roo...\CBE353ProblemSet2Problem1.m
function CBE353ProblemSet2Problem1
function [Qapprox] = Qapprox(T)
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