How to include the integral of a certain function in another .m file function?
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Walter Roberson
2016 年 11 月 17 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!