EE 150 Midterm SLTNS

# EE 150 Midterm SLTNS - SLTNS TO EE 150 MIDTERMS PROBLEM ONE...

This preview shows pages 1–5. Sign up to view the full content.

SLTNS TO EE 150 MIDTERMS PROBLEM ONE MIDTERM ( 25 pts) (a) Red + Blue (k 1 ) b Green [reaction one] Green(k 2 ) b Red + Blue [reaction two] δ Y 1 / δ t = - k 1 Y 1 Y 2 + k 2 Y 3 δ Y 2 / δ t = - k 1 Y 1 Y 2 + k 2 Y 3 δ Y 3 / δ t = k 1 Y 1 Y 2 - k 2 Y 3 (b) Y 1 (t + dt) = Y 1 (t) - dt k 1 Y 1 (t) Y 2 (t) + dt k 2 Y 3 (t) Y 2 (t + dt) = Y 2 (t) - dt k 1 Y 1 (t) Y 2 (t) + dt k 2 Y 3 (t) Y 3 (t + dt) = Y 3 (t) + dt k 1 Y 1 (t) Y 2 (t) - dt k 2 Y 3 (t) (c) Y(1,i+1) = Y(1,i) - dt * k(1) * Y(1,i) * Y(2,i) + dt * k(2) * Y(3,i) Y(2,i+1) = Y(2,i) - dt * k(1) * Y(1,i) * Y(2,i) + dt * k(2) * Y(3,i) Y(3,i+1) = Y(3,i) + dt * k(1) * Y(1,i) * Y(2,i) - dt * k(2) * Y(3,i)

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

View Full Document
(d) dt = .01; % calculate concentrations every dt seconds duration = 100; % stop after duration seconds k = [1e6; 1e-4]; % reaction rate constants Y = zeros(3,1); % Initialize the Y-matrix as a 3x1 matrix. The number % of columsn will grow as we calculate the concentrations % over time Y(1,1) = 4e-7; % initial concentration of red chemical Y(2,1) = 3e-7; % initial concentration of blue chemical for i = 1:(duration/dt) Y(1,i+1) = Y(1,i) - k(1)*Y(1,i)*Y(2,i)*dt + k(2)*Y(3,i)*dt; Y(2,i+1) = Y(2,i) - k(1)*Y(1,i)*Y(2,i)*dt + k(2)*Y(3,i)*dt; Y(3,i+1) = Y(3,i) + k(1)*Y(1,i)*Y(2,i)*dt - k(2)*Y(3,i)*dt; Y(:,i+1) % display the current concentrations end 5pts extra credit for plots % Generate time vector t = 0:dt:duration; figure; plot(t,Y(1,:), 'r+' ); hold on ; % Plot the following concentrations on the same figure; plot(t,Y(2,:), 'b+' ); plot(t,Y(3,:), 'g+' ); PROBLEM TWO MIDTERM ( 15 points) With sound matnum = floor(10 * rand + 1); guess = input( 'Your guess please: ' ); load splat while guess ~= matnum sound(y, Fs) if guess > matnum disp( 'Too high' ) else disp( 'Too low' ) end; guess = input( 'Your next guess please: ' ); end
disp( 'Good Job!' ) load handel sound(y, Fs) % hallelujah! Without sound matnum = floor(10 * rand + 1); guess = input( 'Your guess please: ' ); if guess > matnum disp( 'Too high' ) else disp( 'Too low' ) end; guess = input( 'Your next guess please: ' ); end disp( 'good job!' ) PROBLEM THREE MIDTERM ( 10 points) %Weighted coin Probability for a coin probability of heads =p and %probability of tails =q function [ x y ] = P(n,k,p,q) a=factorial(n); b=factorial(k); c=factorial(n-k); d= a /(b*c); h=p^k; m=q^(n-k); x=d*h*m y=n; disp([x y]);

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

View Full Document
EE 150 Midtrerm Two-----Problems and Solutions Problem One: (a) Write code in C++ wherein the user is asked for the acceleration of gravity, an initial velocity and a time and the computer outputs the height according to the equation, h= v0*t - (g*t*t)/2 , (Do not use functions or procedures): #include <iostream> using namespace std; int main() { cout<<"Input the acceleration of gravity (m/s-s):> ";
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 13

EE 150 Midterm SLTNS - SLTNS TO EE 150 MIDTERMS PROBLEM ONE...

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

View Full Document
Ask a homework question - tutors are online