{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ENME271Test2Summer09Sol

# ENME271Test2Summer09Sol - I ntroduction to MATLAB ENME271...

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

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: I ntroduction to MATLAB ENME271 Closed Book and Closed Notes Test #2 Summer 2009 1 hr 40 min Problems 2, 3 and 4 are to be solved on the computer using MATLAB. The questions in problem 1 are to be answered in handwritten form with the MATLAB software not booted. Turn in your answers to problem 1 before starting to work on the remaining problems. Prob 1. The questions in this problem are to be answered in the contex of MATLAB. (a) What is the definition of a string? (b) Use the str2mat command to make the words Introduction to MATLAB into a string with each word on a different line. (c) Make the vector [2 5 3 7] into a string using the num2str command. (d) Write out the code that uses the disp command to print out the following vector of numbers [23 51 68]. No verbage accompanies the numbers. (e) Given the code: a=3; b=5; c=7; average =(a+b+c)/3; Write the third line of code using disp that will print: The average of a, b and c is 5. The 5 is not to be typed in the disp statement. (f) Given u=[7 3 4 1] and v=[6 2 3], what are the matrices U and V if [U,V]=meshgrid(u,v)? (g) Is it necessary to convert numbers into strings when they are used in a f printf command? (h) If one row of a determinant is obtainable from a combination of the other rows, what can be said about its the determinants numerical value.? (i) What are the requirements that must be satisfied if a matrix of real numbers is to have an inverse? (j) Write the line of code that uses f printf to print: The time has come the walrus said. Prob 2 Measurements taken in a wind tunnel to measure the aerodynamic drag force on a vehicle yield the vector of forces given by F=[23.4 22.1 22.8]. Write and run code using the command disp needed to display the above vector in the form shown below. Configuration #1: Drag Force=23.4 lb Configuration #2: Drag Force=22.1 lb Configuration #3: Drag Force=22.8 lb Prob. 3 It is given that G(x,t) is expressed by G= ∑ n =1 20 1 ⋅ exp( −n ⋅ π⋅ t) ⋅ sin( n ⋅ π⋅ x) n Write and run a program to calculate G for x=0, 0.2, 0.4 and y=0, 0.1, 0.2, 0.3. Display the results in table form using disp. The table is to have the headings t G(x=0) G(x=0.2) G(x=0.4) Do not use looping or the command s um. Use matrix multiplication to multiply sin( n ⋅ π⋅ x) by 1 ⋅ exp ( −n ⋅ π⋅ t ). n Prob 4 Solve the following set of linear algebraic equations by using the matrix method. x+2*y+3*z=13 2*x-3*y+z=4 3*x+4*y-5*z=-4 L N 'ME. ~ (""1110 \ 0 .. ' ).1 \ I <..... '"t # '2 " I 09 A. ~*;\"'j \~ 0 .. ~ . . -I,.,~"..A.;""", a>+' I't.~ ..c . . , (..~'<".... t~""15 _ clc"a.J.. ; ..... ~~\<L 1"",~,,"\$ S _ s-\-.-.lV\'\.o-l (''l'''+-r• .,l.... t~.:...-I) I '\:'0'.1'<'\1<\' " ,,,,_'\,-lL.("'!> b. L~~) J.. ~\'s~ no."2..3 S \ "~J) 0 (' " . Ie e. oI\~'(' C[ \,~ o.."e."jQ. '\) -= \-'--, \ ., ",,,,ott \0;\1' GV'iv.W\'L~trto.yc.~e~) -to ~~~ ~4d \ /0 T~ ~ ~"J b ~ 3 ~1 \ " 'M... """ 'M. -* .. ~)t V\ • ' ""- ..... 'l.-t ' 0,• ~ <\ u.. tl. . .... 6- ~ ns .... "-* 4! <' " '" W\ . .. ' " t­ v..." 't'"' <-'t- '0 c. • ~c> Prob % Prob 2 config=str2mat('Configuration #1: ','Configuration #2: ','Configuration #3: '); force=[23.4 22.1 22.8]; disp([config repmat('Drag Force=',3,1) num2str(force') repmat(' lb',3,1)]) Configuration #1: Drag Force=23.4 lb Configuration #2: Drag Force=22.1 lb Configuration #3: Drag Force=22.8 lb Prob % Prob 3 nn=1:20 xx=0:0.2:0.4; tt=0:0.1:0.3; [n,t]=meshgrid(nn,tt); G=(exp(G=(exp(-pi*n.*t)./n)*sin(nn'*pi*xx); disp(' t G(x=0) G(x=0.2) G(x=0.4)') disp(' ') disp([tt',G(:,1),G(:,2),G(:,3)]) t 0 0.1000 0.2000 0.3000 G(x=0) G(x=0.2) G(x=0.4) 0 0 0 0 1.1806 0.8094 0.5041 0.3228 0.9082 0.7312 0.5459 0.3988 Prob % Prob 4 A=[1 2 3;2 -3 1;3 4 -5]; B=[13 4 -4]'; X=inv(A)*B X=inv(A)*B X= 2.1250 1.0568 2.9205 ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online