Find the area under a certain section of a plot
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a set of data that I have used to plot the graph below. I am needing to find the area of the shaded area but cannot work out how to as I do not know what range of values make up this section and, as the data loops round multiple times there will be a few sets. The data used was two 2000x1 double vectors. Any help would be appreciated.

Note: The shading was done in photoshop as I do not know how to do this in Matlab earlier.
0 comentarios
Respuestas (1)
Samatha Aleti
el 31 de En. de 2020
You can do this by finding the points of intersection of the curve(y1) and the line(y2). Let the intersection points be “[x1,y1]” and “[x2,y2]”. You can find the area using "integral" function.Here is a sample code:
x1 = 1; % Let
x2 = 5; % Let
xmin = min(x1,x2);
xmax = max(x1,x2);
y1 = @(x) (x.^2)+2; % Curve
y2 = @(x) 2*x; % Line
fun = @(x) ((x.^2)+2 - 2*x); % y1-y2
area = integral(fun,xmin,xmax);
0 comentarios
Ver también
Categorías
Más información sobre Smoothing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!