a. Write a Matlab program that will display a menu, which will let the user to:
ID: 664038 • Letter: A
Question
a. Write a Matlab program that will display a menu, which will let the user to:
1. Enter a function in symbolic format
2. Displays the nth root of the function, n is entered/selected by the user - n can be 1, 2,3, or 4
3. Calculates and displays the indefinite integral of the entered function
4. Plot the function, its derivative and its integral [use subplots]
5. Exit
b. Write a Matlab program that will display a menu, which will let the user to:
1. Enter two functions in string format/symbolic
2. Enter two polynomials
3. Differentiate each function (symbolic format)
4. Differentiate each polynomial.
5. Exit
Explanation / Answer
a)
prompt = 'Enter a function in symbolic format '
fun = input(prompt)
prompt = 'Enter n to find the nth root of the function '
n = input(prompt)
root = fzero(fun,n)
display(root)
integral=int(fun)
display(integral)
derivative=diff(fun)
plot(fun,derivative,integral)
b) prompt = 'Enter a function 1 in symbolic format '
fun1 = input(prompt)
prompt = 'Enter a function 2 in symbolic format '
fun2 = input(prompt)
prompt = 'Enter a polynomial 1 '
pol1 = input(prompt)
prompt = 'Enter a polynomial 2 '
pol2 = input(prompt)
derivative1=diff(fun1)
display(derivative1)
derivative2=diff(fun2)
display(derivative2)
derivative3=diff(pol1)
display(derivative3)
derivative4=diff(pol2)
display(derivative4)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.