Integration in m file

조회 수: 4 (최근 30일)
Brian
Brian 2013년 9월 2일
Really struggling with how integration works in matlab, I want to calculate the area under the function x+3 with limits 0 and where x+3 meets tan(x).
I have this but cannot get it to run.
thanks for any help
uplim = fzero(@(x) tan(x)-x-3,1.2)
function y=integrand(x);
y=(x+3);
I1=quad('integrand',0,uplim)
  댓글 수: 1
Brian
Brian 2013년 9월 2일
For clarity this is the original question:
"Calculate the area confined by the functions f(x)=x+3 and g(x)=tan(x) in the first positive interval. From x=0 to the first positive intersection point (where f(x)= g(x)). "
I may have misinterpreted it

댓글을 달려면 로그인하십시오.

답변 (1개)

Roger Stafford
Roger Stafford 2013년 9월 3일
Yes, I think you did misinterpret it. The question asks for the area "confined by the functions f(x)=x+3 and g(x)=tan(x)", not the area under f(x). You need f(x)-g(x) as an integrand. Make a plot of both functions and you'll see the difference.
  댓글 수: 1
Brian
Brian 2013년 9월 3일
편집: Brian 2013년 9월 3일
This is what I have:
uplim = fzero(@(x) tan(x)-x-3,1.2)
function y=integrand(x); y=((x+3)-tan(x)); end
I1=quad('integrand',0,1.3446)
I can get it to run seperately to get an answer but not in single file. Please help, thanks

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by