{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

E7Midterm 2 Solutions 2010(2)

E7Midterm 2 Solutions 2010(2) - Contents Problem 1 Problem...

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

View Full Document Right Arrow Icon
Contents Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Problem 7 Problem 8 Problem 9 format compact Problem 1 for i = 1:20 for j = 1:10 A(i,j) = sin(i*pi/4)*cos(j*pi/3); end end Problem 2 z = func2(3) z = 3 4 2 1 Problem 3 p = 3.5; q = 2; k = -5.5; p3i = (p + q) >= k p3ii = (p < 5) && (k > 0) p3iii = (p > q) || p < q p3iv = p + (q >= k) p3i = 1 p3ii =
Background image of page 1

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

View Full Document Right Arrow Icon
0 p3iii = 1 p3iv = 4.5000 Problem 4 u = [-3 0 0 2 5]; v = [-3 -2 0 2 4]; u < 0 v == u ans = 1 0 0 0 0 ans = 1 0 1 1 0 Problem 5 %two different examples of a correct solution are given below. type func3 function y = func3(month) switch lower(month) case {'january' 'march' 'may' 'july' 'august'... 'october' 'december'} y = 31; case {'april' 'june' 'september' 'november'} y = 30; case 'february' y = 28; otherwise error('not a valid month') end
Background image of page 2
Problem 6 type rec_sum3 function [Sn] = rec_sum3(n) if n == 1 Sn = 1; else Sn = rec_sum3(n-1) + n^3; end Problem 7 a7 = eps(1) < eps(100) b7 = eps(-1) < eps(1) c7 = eps(1) < realmin d7 = floor(-0.49) e7 = ceil(-0.49) f7 = round(-0.49) g7 = fix(-0.49) h7 = 1*2^1 + 1*2^0 + 1*2^-1 + 1*2^-2 i7 = 1111.11 a7 = 1 b7 = 0 c7 = 0 d7 = -1 e7 = 0 f7 = 0 g7 = 0 h7 =
Background image of page 3

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

View Full Document Right Arrow Icon
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}