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

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

View Full Document Right Arrow Icon
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 e1 !
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.

Page1 / 6

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

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