Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

N MATLAB EXERCISE 1.10 AN D E Symbolic integration. MATLAB supports operations w

ID: 3753194 • Letter: N

Question

N MATLAB EXERCISE 1.10 AN D E Symbolic integration. MATLAB supports operations with symbolic variables, that is, all kinds of calculations using symbols in place of real-valued (nu- merical) variables. Symbolic integration is implemented in MATLAB through function intO. Write your own function named integral) that invokes int and has the following input data (integral (f , t , r , a, b)] n order to com pute the integral f ft dr: f and t (their product represents the function to be integrated), r (independent variable of integration), and a and b (integration limits). (integral.m on IR)

Explanation / Answer

Save the following the codes in a script and save as integral.m.

function [int1] = integral(f,t,r,a,b)

f1=f*t;
int1=int(f1,r,[a b]);
end

Solved example,

>> syms x

>> integral(1,1,x,1,5)

ans =

4

>> integral(x,1,x,1,5)

ans =

12

>> integral(x^2,1,x,1,5)

ans =

124/3