MATLAB: Area under the graph graph how can i colored area which is under the graph (eg y=mx+c or any graph)with the boundary condition let say x is 2-5 and find the colored area ? Best Answer You can use fill() to color in the area under the graph of a line, and you can use a numerical integration method like quad() to compute the integral: x = 0:0.01:1; y = 2*x-2; axis([0 1 -2 0]); x1 = [0 1 1]; y1 = [-2 -2 0]; fill(x1,y1,'r'); hold on; plot(x,y,'k','linewidth',2); Q = quad(@(x) 2*x-2,0,1) Related SolutionsMATLAB: Find area of the filled region of a graph trapz(x,y) MATLAB: Call specific expression index from a function carrying multiple expression Break it up in to two different integrations with different functions and add the two results together.You can use helper functions such asrow1 = @(x) x(1,:);row2 = @(x) x(2,:);quad(@(x) row1(f(x)), 1, 5) + quad(@(x) row2(f(x)), 5, 9) Related QuestionIntegrating using quadHow to compute the area of a 2D triangle specified using an object of TriRep class in MATLAB 7.8 (R2009a)How can i fill the common areas of two curves
Best Answer