Given the following integral and its numerical approximation: Write a function c
ID: 644411 • Letter: G
Question
Given the following integral and its numerical approximation:
Write a function called solveIntegral
that takes a user defined ?x as its input and returns the result, i.e. the numerical approximation resulting from the computation. If the input dx cannot evenly increment from 1 to 2 (e.g. dx = 0.15), you may round to the nearest number of increments (e.g. dx = 0.15 has 6.67 increments which rounds to 7 increments or dx = 1/7).
function res = solveIntegral(dx).
Given the following integral and its numerical approximation: Write a function called solveIntegral that takes a user defined ?x as its input and returns the result, i.e. the numerical approximation resulting from the computation. If the input dx cannot evenly increment from 1 to 2 (e.g. dx = 0.15), you may round to the nearest number of increments (e.g. dx = 0.15 has 6.67 increments which rounds to 7 increments or dx = 1/7). function res = solveIntegral(dx).Explanation / Answer
function res = solveIntegral( dx )
increment = 1/dx;
increment = ceil(increment);
dx = 1/increment;
res=0;
for i=1:dx:2
res = res + sin(i)*dx/i;
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.