필터 지우기
필터 지우기

How to shade area of Integral

조회 수: 17 (최근 30일)
Pratik P
Pratik P 2015년 9월 24일
댓글: Star Strider 2015년 9월 25일
Hi I have a simple function y(z) = -1*z^3+4*z^2+-5*z+2 I have the integral in range of x= 0-5. I have the plot of the graph. I would like to shade this area on the graph.
What do I do? THANKS!

채택된 답변

Star Strider
Star Strider 2015년 9월 24일
I’m not quite certain what you want. This shades the area between the x-axis and the value of the integral over the interval (0,5):
y = @(z) -1*z.^3+4*z.^2+-5*z+2;
x = linspace(0, 5);
inty = cumtrapz(x,y(x));
figure(1)
plot(x, inty, '-k', 'LineWidth',1)
hold on
patch([x fliplr(x)], [zeros(size(x)) fliplr(inty)], 'g')
hold off
grid
  댓글 수: 4
Pratik P
Pratik P 2015년 9월 25일
Exactly what I was trying to do. You sir are good thanks, I owe you a Coffey or beer what ever your flavor is.
Star Strider
Star Strider 2015년 9월 25일
My pleasure!
The sincerest expression of appreciation here on MATLAB Answers is what you have already done, that being your Accepting my Answer. If we ever meet, a coffee or beer together would be nice!

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

추가 답변 (1개)

WAT
WAT 2015년 9월 24일
It sounds like you want the area() function.

카테고리

Help CenterFile Exchange에서 Agriculture에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by