Docsity

Practice Exam - Computational Methods | AOE 2074, Exams of Aerospace Engineering

Toggle sidebar
bg1
AOE/ESM 2074
Introduction to Computational Methods
Practice Examination
19 September 2000
1. Given a= [1 : 5] and b= [1 : 3] which of the following are well-defined ?
i) c=a∗bans. well-defined - it’s a 5 x 3 array
ii) c=b∗aans. well-defined - it’s a 3 x 5 array
iii) c=a.∗bans. not well-defined - dot multiplication requires the arrays
be of the same size
2. Given x=[0:.1:1]∗π;y=sin(x) provide one or more Matlab statements to
generate a plot of yvs xwith the points connected by a blue line.
ans. plot(x,y,’b’)
3. The Maclaurin expansion of exp is
exp(x)=1+x+x2
2! +x3
3! +...
provide Matlab script to ask the user for a value of xand a positive integer N.Then
sum the first Nterms of the series and write out the answer as a decimal number with
four digits to the right of the decimal point.
answer is supplied as a separate file
4. Given a=12345;678910;1112131415
describe the fol-
lowing
i) a(:,2:2:5) ans. a 3 x 2 array consisting of all rows and columns 2 and
4. It evaluates to
24
79
12 14
ii) length(a(:)) ans. a(:) is a single column array consisting of all elements
of ain column order. Its length is 15.
iii) a(2,3:5)ans. a 1 x 3 array row 2 columns 3, 4 and 5. It evaluates to
8910
1
pf2

Partial preview of the text

Download Practice Exam - Computational Methods | AOE 2074 and more Exams Aerospace Engineering in PDF only on Docsity!

AOE/ESM 2074

Introduction to Computational Methods

Practice Examination

19 September 2000

  1. Given a = [1 : 5] and b = [1 : 3] which ofthe following are well-defined?

i) c = a′^ ∗ b ans. well-defined - it’s a 5 x 3 array ii) c = b′^ ∗ a ans. well-defined - it’s a 3 x 5 array iii) c = a′. ∗ b ans. not well-defined - dot multiplication requires the arrays be of the same size

  1. Given x = [0 : .1 : 1] ∗ π ; y = sin(x) provide one or more Matlab statements to generate a plot of y vs x with the points connected by a blue line. ans. plot(x,y,’b’)
  2. The Maclaurin expansion ofexp is

exp(x) = 1 + x +

x^2 2!

x^3 3!

provide Matlab script to ask the user for a value of x and a positive integer N. Then sum the first N terms ofthe series and write out the answer as a decimal number with four digits to the right of the decimal point. answer is supplied as a separate file

  1. Given a =

[ 1 2 3 4 5; 6 7 8 9 10; 11 12 13 14 15

] describe the fol- lowing

i) a(:, 2 : 2 : 5) ans. a 3 x 2 array consisting of all rows and columns 2 and

  1. It evaluates to

ii) length(a(:)) ans. a(:) is a single column array consisting of all elements of a in column order. Its length is 15. iii) a(2, 3 : 5) ans. a 1 x 3 array row 2 columns 3, 4 and 5. It evaluates to 8 9 10

  1. Using the array a described in Question 4 examine each ofthe following statements. Ifthe expression is not legal indicate an error. Ifthe expression is legal indicate its value.

i) a(1, 1) > 4 ans. It’s legal and evaluates to 0 , meaning false ii) a(3, 5) > a(2, 3) ans. It’s legal and evaluates to 1 , meaning true iii) a(:, 4) > a(1, 1) ans. It’s legal. The array on the left is a 3 x 1 array consisting of the fourth column of a. The scalar a(1, 1) on the right is (implicitly) multiplied by a 3 x 1 array of ones (ones(3,1). The expression evaluates to a 3 x 1 array of ones

  1. Write a function .m file that will accept an array x and return three numbers: the minimum, the maximum and the average. The first line ofthe function is function [x min, x max, x avg] = mma(x) answer is supplied as a separate file