How to include the integral of a certain function in another .m file function?
5 views (last 30 days)
Show older comments
I have fun1.m file that I want to include in it the integral of cos(x) provided that the integral of cos(x) has to be in a different file too e.g. fun2.m
fun1()
fun2()
0 Comments
Answers (1)
Walter Roberson
on 17 Nov 2016
function r = fun1(x)
y1 = fun2(x); %numeric using all x values
y2 = fun3(x); %symbolic using first and last x values
r = y1(x) - y2(x);
function result = fun2(x)
result = trapz( x, cos(x) ); %one form of numeric integral
function result = fun3(x)
syms X
xint = int(cos(X), X, x(1), x(end)); %symbolic integral between endpoints
result = double(xint);
0 Comments
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!