Working with areas under the curve.

조회 수: 1 (최근 30일)
César Hernández
César Hernández 2019년 9월 9일
편집: César Hernández 2019년 9월 10일
Hi all and greetings.
In the program, i have the graph of a function, and at least one activity ago was created before next abstracted code activity shown below, and the figure is in a variable called "h", the graph range is 0 to 30. In the next code or activity, the respective function of the graph is called "y" as is shown below.
I will get the area under the curve of this function in the range 10 to 20.
How to do to FILL this area range when I click on the figure or graph AND TO SHOW IN A LABEL THE AREA VALUE ?
Maybe a callback function or another idea !!!
CAN SOMEONE HELP ME PLEASE ?
THANKS !!!
a=input('First value: '); % a=10
b=input('Second value: '); % b=20
syms x
y=10*log(2+x^2)+(10/3*x);
area=eval(int(y,a,b));
disp(area);

채택된 답변

David Hill
David Hill 2019년 9월 9일
x=10:.1:20;%or whatever intervals you want
y=10*log(2+x.^2)+(10/3*x);
x=[10,x,20];
y=[0,y,0];
z=polyshape(x,y);
plot(z)
I am sure there is a better way, but I thought of just plotting a polyshape. I don't have too much experience in plotting in Matlab.
  댓글 수: 1
César Hernández
César Hernández 2019년 9월 9일
Hello, thanks for answering.
I will study both scopes for helpping me, that of your code and the polyshape function.
I am also contemplating the possibility of using maybe only the already existing figure.
I think other tips are not over. If no problem. And some of you can barely help me...
Thanks and regards.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R12.1

Community Treasure Hunt

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

Start Hunting!

Translated by