401/501 MATLAB FINAL PROJECT

145 downloads 48 Views 138KB Size Report
report document ( in pdf format, that should include plots and answers). ... report. 2. Project Presentation and practical MATLAB exam ( 10 questions and 5 extra ...
ICSI 401/501

       Fall 2013

401/501 MATLAB FINAL PROJECT

Note 1. Project  is  equivalent  to  one  exam.  You  can  replace  an  exam   grade  with  this  Project  grade, except for the final exam. 2. 1 to 3 students allowed in a group 3. Send  email  at    with  the  name  and  email  address  of  your  group members 4. MATLAB  symbolic  objects  and  built  in  functions  should  not  be  used  to  implement functions.  For  an  example,  you  should  not  use   polyval()  of  MATLAB  to  make  your myPolyval() function. But you can use functions like length(), size() etc. 5. Bonus points  (25%) for functions and scripts that also handles complex numbers. If score adds to greater than 100%, counts as A+ 6. Each group will be allowed 25 minutes for presentation and lab programming test. 7. Deadline 12/4/2013.

Requirements 1. Project file submission through email and hard copy Submit your answer in a compressed file to , with subject “ [401/501] Final Project “. It should contain script file , function files and the report document ( in pdf format, that should include plots and answers). Give appropriate titles, labels, legends, colors for figures and plot smooth curves. Students should also submit the hard copy of the files and the report. 2. Project  Presentation  and   practical MATLAB exam ( 10 questions and 5 extra questions) just after presentation

1

ICSI 401/501

       Fall 2013

Questions Make following functions 1. function output = displayPoly(p) It takes coefficients of polynomial as row matrix, and returns string containing the polynomial. For an example >> displayPoly([ 3 0 1]) should return 3X^2+1 2. function output = myPolyval(p, x) myPolyval function is the implementation of function polyval. Here, p is a row vector and x is a number. >> myPolyval( [3 0 1], 3 ) should return 28. 3. function output = addPoly(p1, p2) The  function  addPoly  should  return   the  sum  of  the corresponding coefficients of given two polynomials. Here, p1 and p2 are both row vector. But note that their length could be different. >> addPoly([2 5], [7 0 1]) should return [7 2 6] 4. function output = substractPoly(p1, p2) >> substractPoly([2 5], [7 0 1]) should return [-7 2 4] 5. function output = myConv(p1, p2) This function is the implementation of MATLAB function conv(). For example, >> p1 = [1 2 3 4]; p2 = [10 20 30]; >> myConv(p1, p2) It should return [ 10

40

100

160

170

120 ]

2

ICSI 401/501

       Fall 2013

6. function [q, r] = myDeconv(p1, p2) This function is the implementation of MATLAB function deconv(). It deconvolves vector p1 out of vector p2, using long division. The quotient is returned in vector q and the remainder in vector r such that p1 = myConv(p2,q)+ r . For example >> p1 = [10 40 100 160 170 120]; p2 = [1 2 3 4] >> [q, r] = myDeconv(p1, p2) It should return q = [ 10 20 30 ] r= [0 0 0 0 0 0]

7. function [der] = myPolyder(p1) It should return the derivative of the polynomial p1. For an example,

>> p1 = [2 5 0]; >> myPolyder(p1); It should return [ 4 5 ]. 8. function [output] = myIntegral(p,c) This function should return the integral of p. When length of c is one, it should compute the indefinite integral of p, with given constant c. But when length of c is two, it should return the definite integral of p from c(0) to c(1). For an example,

>> p = [2 0]; >> myIntegral(p, 5); It should return [ 1 0 5 ]. >> myIntegral(p, [5 10]); It should return 75.

3

ICSI 401/501

       Fall 2013

Using the functions created above, solve the following problems 9. Display a polynomial with coefficients [23 43 63 … 203], with highest power of x on left hand side, in string format, using the function displayPoly. 10. Given that f1(x) = x2, f2(x) = x and f3(x) = f1(x) + f2(x) . Use function addPoly() to find polynomial f3(x). Plot all three lines in the same figure but in different sub­plots, with range of x from ­2 to 2. Use function myPolyval to evaluate f(x). Display each equation of polynomials in their respective subplot title, using function displayPoly. 11. Do same as question 10, but with f3(x) = f1(x) ­ f2(x). And use function substractPoly instead. 12. What is the area of the rectangle with length 4x+10 and width 3x+2? Plot a graph with area in y­axis and x in x­axis ranging from 0 to 15. Express its area in polynomial form in title of the graph. Use functions myConv, myPolyval, displayPoly and others if necessary. 13. Display the polynomial of the width for question 12, if you are given polynomials of its length and its area ( use polynomial of area, that you found in question 12), using function myDeconv. 14. Using Newton’s method find all the real roots of f(x) = x6­1000, with truncation error less than 10­6. Plot the graph for f(x) and draw its real roots, in the same graph, with different colored crosses, if necessary. 15. Shade the region under the line y = ­2x + 2 in the first quadrant and compute its area using myIntegral function. Also, display its indefinite integral, with constant 10.

4