Need help to write a matlab function called myimproperintegr
Need help to write a matlab function called myimproperintegral, which takes 1 input and return one output as the above sample data shown. Function requires a method to calculate improper integral but the tricky part is the approach is uncertain. Correct function should produce the same ouput with at least 10 decimal place.
>> vpa(nyimproper integral (0(x) 2.4*exp (-1.25*x))) ans = 0. 04512909803204167798112977069495 >> vpa(nyimproper integral (0(x)0.7*exp (-1.75*x))) ans = 0. 0020879927799326548474544472977107 >> vpa(nyimproper integrall@(x) 3.1*exp (-1. 25#x))) ans = 0. 05829175162472050072562595381431 >> vpa (myimproperintegral (@(x)10/x 5)) ans = 0. 03069344416702292985789103995966 >> vpa (myimproperintegral (@(x) 9/x 5. 4)) ans = 0. 016143119954676109401374705290344 >> vpa (myimproperintegral (e (x) 3*exp (0. 75*x))) ans = 0. 42154486905684107664895303884221 >> vpa (myimproperintegral (@(x) 6/x 4. 2)) ans = 0. 055422713589375637339996858278556Solution
for integration ww require limits for that along with the function we have to specify lower limt and upper limt.
function x= myimproperintegral(y, lower_limt,upper_limt)
f=(vpa(y));
x=int(f,lower_limt,upper_limt);
end
example 1 myimproperintegral((@(x)2.4*exp(-1.25*x)),0,1)
wher 0 is lower limit of integral and 1 is upperlimt of integral
ans= 1.3699107900284350073762199808362
example 2 myimproperintegral((@(x)0.7*exp(-1.75*x)),0,1)
ans =
0.33049042261982194932771309653345
myimproperintegral((@(x)3.1*exp(-1.25*x)),0,1)
ans =
1.7694681037867285511942841419134
