Area in shades region (Matlab)

So you can indeed combine those two integrals into one.In summary, the conversation discusses how to calculate the shaded region using integrals in MATLAB. The question is whether it is possible to use a single function handle instead of two separate integrals. The answer is yes, as integrals are linear and can be combined into one.
  • #1
gfd43tg
Gold Member
950
50
ImageUploadedByPhysics Forums1407795886.518929.jpg

This is a part MATLAB and part math question. I know for the shaded region, I would usually do
##A_{shaded} = \int_{inter(2)}^{inter(3)} f_{1}(x) \mathrm{d}x - \int_{inter(2)}^{inter(3)} f_{2}(x) \mathrm{d}x##

However, since it appears they want the function handle to be just one line, am I allowed to do

Code:
fh = @(x) -0.1*x.^3 - 0.5*x.^2 - 2.2*x + 9

Since I can't make two integrals and just subtract them?

In other words, would it be correct to say
##A_{shaded} = \int_{inter(2)}^{inter(3)} (f_{1}(x)-f_{2}(x)) \mathrm{d}x##?
 
Last edited:
Physics news on Phys.org
  • #2
Yes, of course, that's correct. One of the first things you should learn about integrals is that they are "linear": [tex]\int_a^b (\alpha f+ \beta g) dx= \alpha\int_a^b f dx+ \beta \int_a^b g dx[/tex]
 
Last edited by a moderator:
  • Like
Likes 1 person

Related to Area in shades region (Matlab)

1. What is a "shades region" in Matlab?

A shades region in Matlab refers to a region of a plot or graph that is filled with a specific color or shade. This can be used to highlight certain data points or to represent a specific area of interest in the plot.

2. How do I calculate the area of a shades region in Matlab?

To calculate the area of a shades region in Matlab, you can use the built-in function trapz or polyarea. The trapz function calculates the integral of a curve, while the polyarea function calculates the area of a polygon. Both of these functions require the coordinates of the points that make up the boundary of the shades region.

3. Can I change the color or shade of a shades region in Matlab?

Yes, you can change the color or shade of a shades region in Matlab. You can specify the color or shade using the 'FaceColor' parameter in the fill function. Alternatively, you can also use the area function, which allows you to specify the color or shade using the 'FaceColor' parameter as well.

4. How can I plot multiple shades regions in one graph in Matlab?

To plot multiple shades regions in one graph in Matlab, you can use the hold function. This function allows you to plot multiple plots or shades regions in the same figure without overwriting the previous ones. You can also use the legend function to add a legend to the plot, specifying the different shades regions.

5. Are there any special considerations when calculating the area of a shades region in Matlab?

Yes, there are a few special considerations when calculating the area of a shades region in Matlab. One consideration is that the coordinates of the points that make up the boundary of the shades region must be in a specific format, such as a column vector or a matrix. Additionally, if the shades region is not a simple polygon, the polyarea function may not give an accurate result. In this case, you may need to use a more complex algorithm to calculate the area.

Similar threads

  • Calculus and Beyond Homework Help
Replies
1
Views
472
  • Calculus and Beyond Homework Help
Replies
6
Views
966
  • Calculus and Beyond Homework Help
Replies
11
Views
1K
Replies
3
Views
355
  • Calculus and Beyond Homework Help
Replies
2
Views
558
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
772
  • Calculus and Beyond Homework Help
Replies
3
Views
306
  • Calculus and Beyond Homework Help
Replies
12
Views
2K
  • Calculus and Beyond Homework Help
Replies
12
Views
1K
Back
Top