midterm solution 06'

midterm solution 06' - Grade for Points on Midterm 1 Points...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Grade for... Points on Midterm 1 Points on Prob 1 Points on Prob 2 Points on Prob 3 60 27 14 19 Problem 1 Category Specific Point Colon operator used correctly At least one value changed correctly All three values changed correctly (give half points if not used end) Linspace format correct Inputs in linspace correct Formula correct (ignoring . operators) . operators used correctly in formula Correct relational condition all used correctly Correct relational comparisions (1 pt each, allow both <= or < & >= or >) Logical | used correctly find used correctly Correctly indexed prices vector syms used correctly Equation for function correct diff used correctly solve used correctly subs used correctly double used correctly y plotted using ezplot Range in ezplot correct Correct differential equation Correct initial conditions (1 each) dsolve used correctly PART A Points Available 3 2 2 Points Awarded 3 2 2 PART B 1 2 2 2 4 3 2 1 2 2 1 1 1 1 1 1 0.5 0.5 2 2 3 0 0 2 2 4 0 0 1 2 2 1 1 1 1 1 1 0.5 0.5 0 0 0 PART C PART D PART E PART F TOTAL this question % ========================= % Part A PartA = 1:6:102; PartA(end-2:end) = 2010; % ========================= % Part B x = linspace(1,pi,25); PartB = 3*log10(x)./((3+x).^-1 + 4*exp(x)); % ========================= % Part C x = [3; 9; 5; 5; 1]; y = [2; 1; 4; 6; 2]; PartC = all(y==2*x); 42 27 PartA = 1:6:102; PartA(end-2:end) = 2010; % ========================= % Part B x = linspace(1,pi,25); PartB = 3*log10(x)./((3+x).^-1 + 4*exp(x)); % ========================= % Part C x = [3; 9; 5; 5; 1]; y = [2; 1; 4; 6; 2]; PartC = all(y==2*x); % ========================= % Part D prices = [21 24 29 19 31 25]; priceOutside_24_28 = prices(find(prices<24 | prices>28)); % ========================= % Part E syms x; y = sqrt(x)*exp(-2*x/5); diffy = diff(y); maxx = solve(diffy); PartE = double(subs(y, x, maxx)); ezplot(y, [0, 20]); % ========================= % Part F PartF = dsolve('D2h = -g - k*Dh', 'Dh(0)=0', 'h(0)=0'); Comments: 28)); '); Problem 2 Category Specific Point File & Function named Prob2 no input variables 3 output variables Points Available 1 1 1 1 1 1 2 3 3 3 3 3 3 3 Points Awarded 1 1 1 1 1 1 2 3 0 0 0 0 0 3 Function Definition Line Comments Input Output Purpose of function syms command Equation for line Equation for circle x values correct y values correct distance correct doubles (1 point each) output variables assigned (1 each) Body of Function TOTAL this question 29 14 function [xVals, yVals, testD] = Prob2 % A vehicle is following a road defined by y=-0.5x+8. A beacon is positioned % at [X,Y]=[3,4]. Computes the xy-position of the vehicle when it is 5 miles % from the beacon. % INPUTS: none % OUTPUTS: xVals... row vector of x-positions of the vehicle (NUMBER) % yVals... row vector of corresponding y-positions (NUMBER) % testD... row vector of corresponding values of distance % between beacon and vehicle given xy values % (this value should be 5 miles) (NUMBER) syms x; % define the road the vehicle moves on y = -0.5*x + 8; % compute the distance from the beacon to any point on the road distanceToBeacon = sqrt((x-3)^2 + (y-4)^2); % solve for the x value(s) that make distanceToBeacon = 5 xVals = solve(distanceToBeacon - 5, x); % substitute this value(s) of x in the equation for the line to get the % corresponding values of y yVals = subs(y, x, xVals); % test the xVals/yVals pairs to see if the distance is 5 miles for all % corresponding pairs testD = subs(distanceToBeacon, x, xVals); % convert xVals = yVals = testD = all results to numeric values double(xVals); double(yVals); double(testD); % substitute this value(s) of x in the equation for the line to get the % corresponding values of y yVals = subs(y, x, xVals); % test the xVals/yVals pairs to see if the distance is 5 miles for all % corresponding pairs testD = subs(distanceToBeacon, x, xVals); % convert xVals = yVals = testD = all results to numeric values double(xVals); double(yVals); double(testD); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Alternate solution %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [xVals, yVals, testD] = Prob2 % A vehicle is following a road defined by y=-0.5x+8. A beacon is positioned % at [X,Y]=[3,4]. Computes the xy-position of the vehicle when it is 5 miles % from the beacon. % INPUTS: none % OUTPUTS: xVals... row vector of x-positions of the vehicle (NUMBER) % yVals... row vector of corresponding y-positions (NUMBER) % testD... row vector of corresponding values of distance % between beacon and vehicle given xy values % (this value should be 5 miles) (NUMBER) syms x y; % define the road the vehicle moves on e1 = -0.5*x + 8 -y; % define the points which are 5 miles from the beacon (a circle with % center (3,4) and radius 5 e2 = (x-3)^2 + (y-4)^2 - 5^2; % solve for the x and y value(s) intersect = solve(e1,e2); % extract the x and y value(s) xVals = intersect.x; yVals = intersect.y; % test the xVals/yVals pairs to see if the distance is 5 miles for all % corresponding pairs testD = sqrt((xVals-3).^2 + (yVals-4).^2); % convert xVals = yVals = testD = all results to numeric values double(xVals); double(yVals); double(testD); Comments: . A beacon is positioned hicle when it is 5 miles vehicle (NUMBER) sitions (NUMBER) es of distance xy values NUMBER) t on the road con = 5 r the line to get the e is 5 miles for all r the line to get the e is 5 miles for all %%%%%%%%%%%% %%%%%%%%%%%% . A beacon is positioned hicle when it is 5 miles vehicle (NUMBER) sitions (NUMBER) es of distance xy values NUMBER) con (a circle with e is 5 miles for all Problem 3 Category Specific Point File & Function named Prob3 2 input variables (1 pt each) 1 output variable Input Output Purpose of function inputs multiplied dot operator used for cell-by-cell multiplication summation of products output variable assgined Points Available 1 2 1 1 1 1 5 5 10 2 Points Awarded 1 2 1 1 1 1 5 5 0 2 Function Definition Line Comments Body of Function TOTAL this question 29 19 function wavg=Prob3(grds, wts) % PURPOSE: to determine a student's overall grade % INPUTS: grds, a vector of grades % wts, a vector of percentage weightings, in decimal form % OUTPUTS: wavg, the student's overall grade wavg = sum(grds.*wts); Comments: decimal form ...
View Full Document

This homework help was uploaded on 03/30/2008 for the course CSE 131 taught by Professor Sticklen during the Spring '08 term at Michigan State University.

Ask a homework question - tutors are online