cee291_sp_10_hw4b

cee291_sp_10_hw4b - CEE 291 Problem Solving Using Computer...

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

View Full Document Right Arrow Icon
CEE 291 Problem Solving Using Computer Tools Homework 3: Matlab Assigned: 2/10/2010 Due: 2/16/2010 by 5:00 pm in the ECOW2 drop box and in the hall box outside 1261 EH. For each file, copy your code into Word and include a plot (if necessary). Problem 1 Conditional statements - One of the most important and fundamental operations in programming is the ability choose different paths to take to get to the end result. The conditional “IF Statement” is the same principle as it is in Excel; however, the syntax is different. In Matlab, the syntax is: if(condition) statements elseif(condition) statements else statements end where: elseif and else are optional. You can include as many elseif conditions as necessary. The conditional statement can include more than one condition with the &&(and) or the ||(or) between conditions. E.g. a.) Create a vector of time from 0 to 24 hours with spacing of 5 minutes. Use a for loop to cycle through the time array and calculate Q. Similar to problem 3 from homework 2, Q changes at different times: Q = 300 + 600 t for 0 < t<= 3 hours and Q = 2100 – 200( t-3) for 3 < t <= 12 hours, and Q = 300 for t > 12 hours. However, treat this conditional flow as the primary outflow from the reservoir. Use an if, elseif, and else statement inside the for loop to calculate Q and make a plot of Q vs. time. Construct a plot of Q vs. t. b.) Now modify your script to include an emergency outlet. Once the primary outlet reaches a discharge of 1800, allocate the rest of the flow to the emergency spillway. This will require nesting an additional for loop into your code. The syntax of a while statement is:
Background image of page 1

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

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

This note was uploaded on 05/04/2010 for the course CEE 291 taught by Professor Hoopes during the Spring '10 term at Wisconsin.

Page1 / 5

cee291_sp_10_hw4b - CEE 291 Problem Solving Using Computer...

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

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