Question: Matlab LAB 5 Objective to use Select Case, Anonymous Functions, and get experience writing functions and using Dialog input techniques. Read the INTEGRATION & ROOTS
Matlab LAB
Objective to use Select Case, Anonymous Functions, and get experience writing functions and using Dialog input
techniques.
Read the INTEGRATION & ROOTS document. Study the Integration equations and note this is to be implemented with a
for loop. Also study the Roots method which converges, this is to be implemented with a while loop.
Requirements:
Write a script and functions. Write the program to cycle until the users chooses to stop.
The script will have an outer while loop and use dialog boxes and switch case statements as described below.
The three functions are as follows:
note a below is the left value of and is the right value of x in the interval of interest
a Integrate a function using the Trapezoidal Method, inputs are function, and n # of slices output is the
integral value.
b Integrate a function using the Simpson Method, inputs are function, and # of slices output is the
integral value.
c Find the ROOT of a function using the ROOTS algorithm, inputs are function, b and epsilon a small #
output is the final root of
Script flow should be as follows:
Using a Dialog button with buttons see ForvsWhile.m file have the user chose one of the anonymous
functions. The selected Anonymous function will be used in the three Programmed functions Integral by
Trapezoidal Method, Integral by Simpson Method, or Root by BiSection Method.:
aNOTE integral about root about Method can affect accuracy for both
solutions use slices and epsilon of your choice but greater than recommend
bNote you should be able to set any range for integral and a specific range for one of the
roots
c You pick the but be sure you can define a range for the roots
Using an input statement ask the user to pick Trapezoidal, Simpson, or ROOT. Make sure you are consistent
with string or number. You can use what you are comfortable with. The input variable will then be used in a
switch case statement. Each case will do the following:
a First case Trapezoidal Integral
i Ask the user for the inputs and function was already chosen in
ii Call the function with parameters is from the anonymous selection above.
iii. Use fprintf to output the answer
b Second case Simpson Integral
i Ask for the three inputs and function was already chosen
ii Call the function with parameters is from the anonymous selection above.
iii. Use fprintf to output the answer
c Third case ROOTs
i Ask for the three inputs a b and e function was already chosen
ii Call the function with parameters is from the anonymous selection above.
Remenber is a very small # eg or
Special NOTE use and on different runs to compare the accuracy of the
answer you get.
iii. Use fprintf to output the answer
Write three functions:
a Integral by Trapezoidal method
b Integral by Simpson Method
c Find Root
These functions inputs and output are described above. The INTEGRATION & ROOT doc describes the algorithm
inside these functions.
EXTRA CREDIT pts: For Item instead of input statement use a second dialog box with buttons.
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
