Integral as part of a function

2 views (last 30 days)
Jhed Maui Kajiyama
Jhed Maui Kajiyama on 28 May 2022
Edited: Jan on 28 May 2022
I want to input this as a function of x in matlab because I need to plot it
how do I input this definite integral inside the function?

Accepted Answer

Jan
Jan on 28 May 2022
Edited: Jan on 28 May 2022
% As anonymous function:
f = @(x) integral(@(t) 2 * sqrt(0.0625 - t.^2), -0.25, x - 0.25) / 0.0981747704247;
f(13)
ans = 1.9999e+00 + 1.6526e+03i
% As function:
g(13)
ans = 1.9999e+00 + 1.6526e+03i
function y = g(x)
y = integral(@(t) 2 * sqrt(0.0625 - t.^2), -0.25, x - 0.25) / 0.0981747704247;
end

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!