{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cee291_sp_10_hw4b

# cee291_sp_10_hw4b - CEE 291 Problem Solving Using Computer...

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

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. if(x>4 && x<10), if(x<3 || t >10) 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.

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

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

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern