Clear Filters
Clear Filters

How to calculate the area in table and certain coordinate

5 views (last 30 days)
Area Centroid
____ ________________
9 147.67 109.11
27 146.81 108.52
43 147.09 109.7
54 147.81 109.35
12 146.17 134.42
56 147.73 109.46
21 146.48 134.05
53 147.83 109.26
20 147.3 134.25
2 126.5 146
43 147.67 108.63
24 147 134.04
2 126.5 146
45 147.93 108.87
20 147.25 133.95
10 125.5 146.8
37 147.43 108.89
16 147.31 133.56
6 126.17 147
36 147.39 108.81
12 147.92 133.75
6 126.5 147
34 147.32 108.91
12 147.92 133.75
8 126.5 146
29 147.69 109
13 147.54 133.38
8 126.5 146
28 147.71 109.11
7 148.14 134.43
8 126.5 146
28 147.71 109.11
6 148 134.5
7 126.43 145.71
28 147.71 109.11
7 147.29 133.71
1 106 132
8 126.25 145.5
25 147.4 109.08
7 147.29 133.71
1 106 132
5 126.4 145.2
31 147.03 108.87
9 147.33 133.78
2 105.5 132
6 126.17 145
31 147.03 108.87
9 147.33 133.78
1 106 132
3 125.67 144.33
31 147.03 108.87
9 147.33 133.78
31 147.03 108.87
9 147.33 133.78
28 147.43 109.39
10 146.7 133.6
25 147.08 109.4
11 147.55 133.18
28 147.43 109.39
5 146.8 133.2
20 147.7 109.55
3 149 132
12 147.92 109.33
Hi all, I have data above.Anyone know how to calculate the total are ? Let say Inwant calculate the the total are that have coordinate (147 109) and (146 108), is it like this the command sum([146:147 108:109])?

Accepted Answer

C B
C B on 3 Oct 2021
Edited: C B on 3 Oct 2021
Hello @mohd akmal masud, You need to take out Area index then sum it where centroid is within you range.
You can do that like following
Area = [9;27;43];
Centroid = [146.67 108.11; 146.81 109.52; 146.09 108.7];
T = table(Area ,Centroid);
%check in all value which are 147 in column 1 and 109 in column 2
trueIndex = ((147>=T.Centroid(:,1) & T.Centroid(:,1)>=146)&(109>=T.Centroid(:,2) & T.Centroid(:,2)>=108));
%add all area which have 147 and 109
sum(Area(trueIndex))
Or in one liner if you want
sum(Area(((147>=T.Centroid(:,1) & T.Centroid(:,1)>=146)&(109>=T.Centroid(:,2) & T.Centroid(:,2)>=108))))
Please mark answer as accepted if it satisfies your requirement.
  13 Comments
mohd akmal masud
mohd akmal masud on 13 Oct 2021
yah..
T =
1593×2 table
Area Centroid
__________ __________________________
7.9862e+05 128.24 134.13 72.539
1 16 139 1
13 36.462 99.308 1.1538
75 69.987 156.37 3.2267
1 73 229 1
1 79 192 1
31 85.903 175.84 1.3226
80 95.75 128.22 1.575
21 95.333 169.38 1.1429
2095 90.026 119.06 7.0692
7 105.71 36 1
1 108 145 1
2 110.5 146 1
1 113 230 1
1 115 147 1
1 118 148 1
1979 128.44 174.24 6.4785
1 142 86 1
9 148.89 229.22 1
1275 152.11 172.63 8.7867
C B
C B on 13 Oct 2021
in this case there are 2 area what do you want with them 1st one or second or sum?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!