THIS NEEDS TO BE ANSWERED IN MATLAB CODING ONLY please use screen shots so I can
ID: 3868455 • Letter: T
Question
THIS NEEDS TO BE
ANSWERED IN MATLAB CODING ONLY please use screen shots so I can follow along because these two questions have been answered, but I do not understand how it works!
See problems under image below....
I KNOW HOW TO CALCULATE ALL OF THESE PROBLEMS ALREADY I DON'T KNOW HOW TO CODE IN MATLAB, so if possible show me the steps so I understand, Thank you.
ALSO CAN YOU PLEASE ONLY USE ONE (1) function M FILE
my code doesn't work (see screen shot)
outputs errors
this needs to be able to run all of this data (see below)
>> vpa(myimproperintegral(@(x)4.5*exp(-0.75*x)))
ans =
0.62537006964643897429360481489339
>> vpa(myimproperintegral(@(x)9/x^5.4))
ans =
0.014553394300179510195438787339928
>> vpa(myimproperintegral(@(x)2.6*exp(-1.25*x)))
ans =
0.044901566777145309907390360099547
>> vpa(myimproperintegral(@(x)4.3*exp(-1.5*x)))
ans =
0.03026028154853748901738458470208
>> vpa(myimproperintegral(@(x)1.5*exp(-1.5*x)))
ans =
0.0105559121680944729130411341984
>> vpa(myimproperintegral(@(x)8/x^5.6))
ans =
0.010047002638331100110209488082967
>> vpa(myimproperintegral(@(x)4.5*exp(-1.75*x)))
ans =
0.013086146761883056352775473286745
>> vpa(myimproperintegral(@(x)0.1*exp(-0.75*x)))
ans =
0.010917530494114030472942200552035
>> vpa(myimproperintegral(@(x)7/x^4.2))
ans =
0.05795968985412595989684411807316
>> vpa(myimproperintegral(@(x)7/x^5))
ans =
0.018804938271604938271604938271605
Explanation / Answer
try to run below code...
function result = myimproperintegral(f)
f = @(x)9./x.^5.4;
xstart = 3;
xend=4;
prevapproxl = integral(f,xstart,xend);
xend++;
approxl = integral(f,xstart,xend);
while(prevapproxl - approxl >= 10.^-2)
prevapproxl = approxl;
xend++;
approxl = integral(f,xstart,xend);
end
result = approxl;
end
Please let me know if you are getting incorrect result.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.