Hello,
I have this function:
fun = @(x) (x^2 + 2)
q=int(fun,x,[-1,2])
q=9
How do i plot this fun function with the shaddes are betweeen -1, 2 of the integral?
Thanks

 채택된 답변

Star Strider
Star Strider 2021년 3월 30일

0 개 추천

I am not sure what you want.
Try this:
fun = @(x) (x.^2 + 2)
q = integral(fun,-1,2)
xv = linspace(-2,3);
xseg = xv(xv>=-1 & xv<=2);
figure
plot(xv, fun(xv))
hold on
patch([xseg fliplr(xseg)], [fun(xseg) zeros(size(xseg))], 'b', 'FaceAlpha',0.25)
hold off
text(mean(xseg), q*0.1, sprintf('$\\int_{%d}^{%d}x^2+2 dx = %d$',-1,2,q), 'Horiz','center', 'Vert','middle', 'Interpreter','latex')
.

댓글 수: 2

Rodrigo Toledo
Rodrigo Toledo 2021년 3월 30일
this is exactly what i needed. Thanks.
Star Strider
Star Strider 2021년 3월 30일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

제품

질문:

2021년 3월 30일

댓글:

2021년 3월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by