Question: Anonymous Functions and Function Handles. Remember to write text that ex - plains your solution and introduces all code and output that you include. This
Anonymous Functions and Function Handles. Remember to write text that ex plains your solution and introduces all code and output that you include. This text should come first, before all code and output.
First write a function simpf a b n which uses Simpsons rule
Zbhh i
fxdx fxfxfxfxfxnfxnfxn a
where h ba denotes the numerical step size for a given even integer n to approximate the n
definite integral of fx over the interval ab The implementation of the function will be very similar to that of trap.m we saw in the tutorial. Next, write a script file in which which you will define the functions
fx sinx x in pi gx ecosx x in pi
as anonymous functions and then use simp to compute the definite integral of each function over the given interval. Use n and print a table as follows:
n If Ig
You should note that the formula for Simpsons rule has a similar pattern to Homework Problem Consider incorporating your solution from there into this problem.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
