lec02_09082006 - 10.34, Numerical Methods Applied to...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
10.34, Numerical Methods Applied to Chemical Engineering Prof. William Green Lecture 2: Solving Systems of Linear Equations Sample Function and Computing Tips function k = rate(T, params) % computes rate constant given temperature and Arrhenius parameters % Bill Green 9/8/06 % inputs: % T [=] Kelvin % params = [A; n; Ea] % A [=] 1/second % n unitless exponent % Ea [=] kj/mole % % output: % k [=] 1/second % % unpack params A=params(1); N=params(2); Ea=params(3); R = 8.314; % gas constant J/mole-Kelvin Ea=1000.*Ea; K=A.*(T.^n).*exp(-Ea./(R.*T)); One additional feature is to include input/output example at bottom of code: %Tvec = linspace(300,1200); %params = [1e9;0.5;82]; %kvec=rate(Tvec,params); %kvec(3) %ans = 6.1551e-004 Use a lot of ‘%’ comments for 1) The graders to give you partial credit 2) To help you understand your programs when you review 3) For your classmates if they need to operate your program TEST your program in pieces!! Otherwise you write a long program and you have no idea where the problem is. “If you’re going to build a laboratory apparatus, you check the power supply, you check if the tubes leak, if the safety features are in place, etc, before you run experiments. It’s the same thing with software.” In MATLAB you don’t have to describe the dimension of each array. This can be used to your advantage by setting up the function as follows:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

lec02_09082006 - 10.34, Numerical Methods Applied to...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online