How to calculated the total area in binary

1 visualizzazione (ultimi 30 giorni)
Hi all, I have one set data below. Anyone know how to calculate the total area of particular coordinate?
let say I want to calculate the total area that have centroid (150 111) and (150 110) used this cide but have error
data = T;
T.Area = T(:,1);
T.Centroid = T(:,3:2);
Input1 =[150 111];
Input2 =[150 110];
output = sum(T.Area(((Input2(1)>=T.Centroid(:,1) & T.Centroid(:,1)>=Input1(1)))))
output2 = sum(T.Area(((Input2(1)>=T.Centroid(:,1) & T.Centroid(:,1)>=Input1(1))&(Input2(2)>=T.Centroid(:,2) & T.Centroid(:,2)>=Input1(2)))))
T =
1593×2 table
Area Centroid
__________ __________________________
17 12 143 82.353
2 35.5 161 81
5 73.6 137 82
22 90.864 203.95 83.955
2 106 219.5 81
1979 149.49 135.39 87.524
3 150 213 81
6 153.5 204 81.333
1 240 168 81
10 241.5 165.1 82.7
3 14 99.333 82.333
1 40 151 82
18 99.5 219.67 82.389
2 102 228.5 82
1 116 203 82
2 149.5 45 82
3 156 216.67 82.333
2 180 22 82.5
1 185 24 82
2 196 206.5 82
1 248 128 82
1 10 124 83
2 13 106.5 83
1 14 155 83
2 15 157.5 83
1 16 93 83
2 60.5 218 83
2 96 211.5 83
1 100 231 83
1 101 233 83
1 113 209 83
2 118 203.5 83
1128 127.76 147.14 87.473
4 155.5 212.5 83.5
3 168 160.33 83.667
3 177.67 195.33 83
3 181.33 193.33 83.667
7 183 23.286 84.286
3 218 65 83
2 220 153 83.5
3 221.33 164.67 83
11 11 132.45 85
1 27 117 84
3 44.667 147.67 84
1 62 187 84
9 85.667 204.56 84
5 93.8 212.6 84.6
352 107.86 134.48 87.835
9 123.11 204.33 84.889
7 147.71 219.86 84
1 168 212 84
177 176.88 197.01 89.311
3 176 215 84
1 207 167 84
1 209 163 84
1 217 176 84
2 221.5 155.5 84
2 237 175 84.5
2 10 126 85.5
8 11.75 111.38 86
2 12 139.5 85
2 13 106 85.5
3 17 90 86
2 18 88 85.5
2 28 146.5 85
1 40 189 85
1 41 187 85
1 94 219 85
48 98.938 44.771 86.771
1 104 218 85
21 109.43 45.476 87.381
8 116.5 218.5 85
3 208.33 191.33 85.333
3 212.67 180.33 85
4 238.5 172.25 85.75
2 14 154 86.5
5 34.8 73 86.6
1 69 190 86
3 126 231 86
1 176 21 86
1 179 22 86
4 180.5 200.5 86
2 185 191 86.5
4 191.5 215 86
3 217.33 177.67 86
2 242 163 86.5
20 10.65 126.1 90.2
2 12 142.5 87
3 35.667 144.67 87
1 39 143 87
2 61 222.5 87
15 75.067 128.4 87.8
1 139 204 87
4 161.25 212 87
1 161 217 87
1 200 206 87
19 218.89 175.05 88.105
2 236 177 87.5
6 240.67 167.33 87.333
1 12 148 88
1 13 126 88
3 33 177 88
1 42 166 88
2 63 202.5 88
2 65 194.5 88
42 87.833 210.9 89.381
1 113 219 88
1 130 232 88
2 142 203.5 88
2 167 220.5 88
2 168 215.5 88
9 196 213.78 88.444
2 238 173 88.5
1 11 134 89
1 28 146 89
3 46.333 166.67 89
1 129 235 89
1 183 24 89
1 212 81 89
7 21.143 81.143 90.857
39 54.051 193.74 91.282
1 114 219 90
8 147.38 55 91.75
4 163.5 212.5 90
5 168.4 221.6 90
2 169 216.5 90
1 172 219 90
6 180.33 212.83 90
2 219.5 71 90
2 11 130.5 91
1 16 94 91
4 17 90.5 91.5
3 74.667 141.33 91.333
2 189 216.5 91
4 245 149 91.5
1 245 152 91
2 247 124.5 91
4 27.5 141 92.5
2 52 204.5 92
1 89 212 92
2 105 218.5 92
1 118 219 92
2 137 203.5 92
7 155.43 215.71 92
2 156 211.5 92
2 159 218.5 92
250 183.65 197.84 96.52
4 184.75 201 92.75
2 187 213.5 92
3 219 174 92
1 33 177 93
1 50 207 93
1 85 227 93
6 89 207.5 93
48 92.542 204.85 96
1 148 218 93
3 170 214 93
1 204 205 93
2 246 116 93.5
18 15.833 94.778 97.278
1 41 162 94
1 80 228 94
4 83 226.75 94.75
  1 Commento
C B
C B il 13 Ott 2021
What will be expected answer for
% total area that have centroid (150 111) and (150 110)

Accedi per commentare.

Risposta accettata

yanqi liu
yanqi liu il 14 Ott 2021
data = T;
T.Area = data(:,1);
T.Centroid = data(:,[3 2]);
Input1 =[150 111];
Input2 =[150 110];
dis1 = T.Centroid-repmat([150 111],length(T),1);
dis1 = dis1(:,1).^2+dis1(:,2).^2;
dis2 = T.Centroid-repmat([150 110],length(T),1);
dis2 = dis2(:,1).^2+dis2(:,2).^2;
ind = dis1<=1 & dis<=1;
sum(T.Area(ind))
  9 Commenti
mohd akmal masud
mohd akmal masud il 14 Ott 2021
its same error, because no changes
ci =
table
Centroid
__________________________
128.24 134.13 72.539
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript and a variable
subscript, as in t(rows,vars). To select variables, use t(:,i) or for one variable t.(i). To select rows, use t(i,:).
yanqi liu
yanqi liu il 15 Ott 2021
data = T;
save data.mat data
sir,can you run and save data.mat , then upload it to develop

Accedi per commentare.

Più risposte (1)

yanqi liu
yanqi liu il 13 Ott 2021
data = T;
T.Area = T(:,1);
T.Centroid = T(:,[3 2]);
Input1 =[150 111];
Input2 =[150 110];
dis1 = T.Centroid-repmat([150 111],length(T),1);
dis1 = dis1(:,1).^2+dis1(:,2).^2;
dis2 = T.Centroid-repmat([150 110],length(T),1);
dis2 = dis2(:,1).^2+dis2(:,2).^2;
ind = dis1<=1 & dis<=1;
sum(T.Area(ind))
  1 Commento
mohd akmal masud
mohd akmal masud il 14 Ott 2021
Some minor error
T.Centroid = T(:,[3 2]);
Variable index exceeds table dimensions.

Accedi per commentare.

Categorie

Scopri di più su Convert Image Type in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by