Is there any function for calculate the area content bounded by the curve?

Dear all
I have this curve:
and I would like to calculate the area content, which is bounded into this curve. Is there any functions for this? Thank you for your answers.

Answers (1)

The polyarea function will probably do what you want.

12 Comments

Yes, it works, but it didn´t work for data in cell. I attach this data. How I can do this for this data?
This works with the cell2mat function:
d = load('tmp.mat');
Data = cell2mat(d.tmp);
A = polyarea(Data(:,2), Data(:,1));
figure(1)
plot(Data(:,2), Data(:,1))
grid
axis equal
text(median(Data(:,2)), median(Data(:,1)), sprintf('Area = %.0f',A), 'HorizontalAlignment','center')
I apologise for the delay. Firefox only wanted to download your ‘.mat’ file as a text file (even after doing the upgrade), so I had to switch to Internet Explorer.
Thank you for your answer. It´s work. But, do you think that these two area contents are the same? Because according to the visual assessment aren´t the same. But I´m not expert...What do you think?
My pleasure.
If your data in ‘tmp’ are derived from another source, you will have to scale the area to the units in your original data.
The easiest way to do that is to scale your x and y data to those units. The area should then be correct.
Please...And how I scale these data to those units? I got tmp data from function fourier_fit.
You have to find them from your original data. For example, if they are pixel data, you have to know the size of the pixels in terms of the original image. If you know the physical dimensions your image represents, and the number of pixels in it in each dimension, you can calculate the size of each pixel in actual length units in each dimension. That becomes your scale in each dimension.
Okay, so if I understood it well, my original data in this case is this image:
I attach this image too.
What is my size of the pixels?
What is the radius of the circle (in length units, such as centimetres)? (My guess would be about 25 cm, but I do not have that information.)
Does not matter, I've solved it differently. Now, I have this image:
it is struct and I would like to rotate this image.
I tried this:
figure(6);
show_fem(img_okoli);
Mod = struct2cell(img_okoli);
Mod = cell2mat(img_okoli);
Mod = imrotate(img_okoli,90);
Can you advice me?
I am not certain what sort of plot the ‘show_fem’ function produces. I cannot find it in an Internet search.
See if the rotate function will work with it. Otherwise the view function could work.
@Walter — Thank you.
Looking through the code, using the view function, or rotating it manually in the GUI, would seem to provide the best option.

Sign in to comment.

Asked:

on 24 Apr 2017

Commented:

on 26 Apr 2017

Community Treasure Hunt

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

Start Hunting!