{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Assignment 06

# Assignment 06 - University of California Berkeley Fall...

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

University of California, Berkeley Department of Mechanical Engineering Fall Semester 2008 Instructors: M. Frenklach, R. Horowitz E7, Assignment 6 Assigned: Friday, October 10, 2008 Due: 12:00 pm, Friday, October 17, 2008. This assignment is an introduction to using definite and conditional loops in MATLAB . As before, turn in the hard copy of your published file to the drop boxes in Etcheverry 1109 and upload the soft copies of your script and your functions (the M-files) to bspace. Do not forget to name your main M-file as lastname_firstname_SID_lab06.m WARNING: Since this assignment introduces loops, you might encounter problems where your loop goes into infinite repetitions. In such a case, you can press CTRL+C (Ctrl and C keys simultaneously) in the command window to break the current MATLAB operation. NOTE: Do not forget to display the contents of your user-defined functions using the command type MATLAB commands * introduced in this assignment: magic, rand, tic ... toc 1. In this problem, you will create several simple for loops. a) Using a for loop, write a script that will display the square of each integer from 1 to 10. b) Using a for loop, write a script that will display the natural logarithm of all integers from 13 to 20 in reverse order. c) n! is defined as n*(n-1)*(n-2)*...*1 and 0!=1. Write a function called my _ factorial that takes an input integer value n and, using a for loop, calculates the factorial. Test this function with input n = 8 . d) The exponential function can be approximated by x 1 e 1 !

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