PGE 310 - HW 4(2) - The University of Texas at Austin Fall...

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

View Full Document Right Arrow Icon
The University of Texas at Austin Fall 2011 - PGE 310: Formulation and Solution in Geosystems Engineering Homework #4: If Statements and Loop Structures Due Date: Thursday September 22 nd 2011 Do NOT forget to follow the guideline for submitting homework (Attached to the end of this file) 1. Summation and Product Using Loops (By HAND) Consider the following vector, x , and matrices, A and B : ] 2 8 6 1 2 3 2 5 5 3 4 2 3 1 [ x 2 4 1 2 1 4 1 2 4 A 1 4 1 2 1 2 1 1 2 B Calculate the following by hand and then write (by hand) the equivalent MATLAB loop a. 10 5 2 ) 1 ( i i i b.   3 1 3 1 2 3 ) ) ( ( ij j ji i B A A c. 3 1 1 ) ( i ii i B x d. 3 1 3 1 ) ( j j i ij x A j e. 2 2 2 16 15 .... 6 5 4 3 2 1 Hint: “ ” symbol is for a product and is analogous to the summation symbol: 10 ... 4 3 2 1 10 ... 4 3 2 1 : . . 10 1 10 1 i i i i g e (30 %)
Background image of page 1

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

View Full DocumentRight Arrow Icon
2. Loop Structure (By HAND) Consider the following MATLAB code written in a script file segment and determine the value of “ ires ” and/or jres ” at the end of each of the loops, and also the number of times each loop executes. Clearly show your intermediate calculation steps for each time the loops execute. A. ires = -3 jres= 2* ires; for j = 1:3:10 jres = ires * jres; ires = jres / j; end B. ires = 2; jres = 6; for i = -9:-3:-15 if i < - 11 jres = ires^2; else ires = jres^2; end end C. ires = 100; jres = 2 while ires > 10 jres = jres^2; ires = ires – jres; end D. jres = 15 ; ires = -3; while abs(ires*jres) < 300 or jres< 100 ires = ires + 2; jres = jres ^2 / i if i > 14 break end end jres = jres + 1; end (30 %) 12
Background image of page 2
3.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/04/2011 for the course PGE 310 taught by Professor Klaus during the Fall '06 term at University of Texas at Austin.

Page1 / 5

PGE 310 - HW 4(2) - The University of Texas at Austin Fall...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online