Matlab

faaldawood
  1. Use the Matlab function, integral(·) to numerically integrate the function, y=x2 2x4 from1to5.Youwillhavetocreateafunctionandpassafunction

    handle to quad(·). See Attaway 14.5. (Answer = ~4/3)

  2. Write a function using “for-loops” to integrate the mathematical function in Problem #1 using Rectangular integration. Use “Left-corner” Rectangular Integration. The function should take as inputs, a, b, N and a function handle and output the integrated result. (try N=1000) (Answer = ~4/3)

  3. Using “for-loops”, integrate the same function in Problem #1 using Trapezoidal integration. Use the same function structure as in Problem #2. (Answer = ~4/3)

  4. Using “for-loops”, integrate the same function in Problem #1 using Simpson’s 1/3 and 3/8 Rule integration. Use the same function structure as in Problem #2. (try N=100) (Answer = ~4/3)

  5. Write three different functions using “for-loops” to integrate the Gaussian normal distribution curve from [-σ, σ ], [-2σ, 2σ ], and [-3σ, 3σ ], using Rectangular integration. Perform all three types of Rectangular integration: 1) Left-corner; 2) Midpoint and 3) Right-corner. Use the same function structure as in Problem #2. Let μ be 0 and let σ be 1. (try N=1000)

    (Answer = ~68.2%,~95.4%,~99.7%)

page1image16440
page1image16600

21 1x−μ

y= exp σ2π 2σ

page1image18224
page1image18384
page1image18544
page1image18704

 

  1. Using “for-loops”, integrate the Gaussian function in Problem #5 using Trapezoidal integration. Use the same function structure as in Problem #2.

  2. Using “for-loops”, integrate the same function in Problem #5 using Simpson’s 1/3 and 3/8 Rule integration. Use the same function structure as in Problem #2. (try N=100)

  3. Write a function using “for-loops” to integrate the 2-dimensional Gaussian normal distribution curve from [-σ,σ]for both x and y using “Midpoint” Rectangular integration. Use the same function structure as in Problem #2. Use variablesbutletρ,μx andμy be0andletσx andσy be1.Youmayhavetomake the dx and dy values smaller to obtain accurate answers. (try N~3000)

    (Answer = ~46.6%)

(y−μ ) 2ρ(x−μ )(y−μ ) f(x,y)= expx+yxy

2
2

1 1(x−μ)

2πσσ1ρx y xy

2 2(1−ρ2) σ2 σ2 xy 

page2image9760
page2image9920
page2image10080
page2image10240
page2image10400
  1. Use the Matlab function, integral2(·) to numerically integrate the 2D function given in Problem #8 integrating from [–2σ, 2σ ] and integrating from [-3σ, 3σ ] for both x and y. (Answer = ~91.1%,~99.46%)

  2. Write a Matlab function to numerical differentiate a function, y = xsin2 (x) +1. The function signature is function funk_prime=differentiate(funk,x) where funk is the generic function to be differentiated and x ranges from -4 to 3. Plot both y and y’.

EXTRA CREDIT

11. Write a function using “for-loops” to rotate an image of any size. Test your function using ‘cameraman.tif’ as the input image and rotate the image counter-clockwise 30 degrees and display the result. (HINT: Use inverse mapping by looping over the output pixels and calculating the rotated pixel position in the input image, you can use either nearest-neighbor or bilinear interpolation) 

    • 10 years ago
    • 20
    Answer(0)
    Bids(0)