Hello everyone I have an excel file with 2 columns (x and y) and 2111 rows. What my program does as far now is to : call the file from matlab, place all the couples (xi,yi) on the graph and construct one circle for each point of the excel matrix
clc
close all
clear all
DataSelect='celapossofare';
[v,X,vX]=xlsread('celapossofare.xlsx');
x=v(:,1);y=v(:,2);
plot(x,y,'.');
r = x*0 + 1000;
CIP=circles_new(x,y,r);
Now I would like to calculate the overlapping of this circles (that has as centre xi, yi).
Can someone help me?
[EDIT] CHIARA'S "ANSWER" MOVED HERE:
what I did is the following code
d2 = (x2-x1)^2+(y2-y1)^2;
d = sqrt(d2);
t = ((2*r)^2-d2)*(d2);
if r <= d <= 2*r
A = 2*r^2*acos(d2/(2*d*r))-1/2*sqrt(t);
elseif d > 2*r
A = 0;
else % d < r
A = pi*r^2;
end
My problem Is very stupid but I just started to prgram in matlab.
I don't know How to take x,y from a matrix that I have in excel

4 件のコメント

Sara
Sara 2014 年 6 月 4 日
Do you need the points where the circles intersect or the area of the overlap?
chiara
chiara 2014 年 6 月 5 日
I would like to calculate the area where the circles overlap Thank you for your comment
Roger Wohlwend
Roger Wohlwend 2014 年 6 月 5 日
Do you want to know just the size of the area or do you want to know exactly where it is so that you could highlight it in a diagram for example?
chiara
chiara 2014 年 6 月 5 日
I prefer to know exactly where it is if possible

サインインしてコメントする。

 採用された回答

Roger Wohlwend
Roger Wohlwend 2014 年 6 月 5 日

0 投票

Construct a grid. Calculate for each point the distances to the circle centers. All points whose distances to the circle centers are smaller than the radiuses belong to the overlapping area.

3 件のコメント

John D'Errico
John D'Errico 2014 年 6 月 5 日
Of course, this will be highly inexact, being equivalent to a very simple integration, essentially rectangle rule. Note that an exact answer was asked for (not that that will be possible.)
Roger Wohlwend
Roger Wohlwend 2014 年 6 月 5 日
編集済み: Roger Wohlwend 2014 年 6 月 5 日
Yes, I admit it is not very exact. Perhaps a better solution is taking paper and a pencil and calculate a formula.
Image Analyst
Image Analyst 2014 年 6 月 5 日
With a fine enough grid, it can be made as close as is needed. Perhaps it's just an exercise in numerical analysis. She could decrease the grid spacing until the answer "levels out" and becomes relatively stable.

サインインしてコメントする。

その他の回答 (2 件)

Sara
Sara 2014 年 6 月 5 日

0 投票

If you have the mapping toolbox, you can use polybool.
chiara
chiara 2014 年 6 月 5 日

0 投票

What I did is this but I have a silly problem I don't know how to take x1,x2 y1,y2 from a matrix that I have in excel
d2 = (x2-x1)^2+(y2-y1)^2;
d = sqrt(d2);
t = ((2*r)^2-d2)*(d2);
if r <= d <= 2*r
A = 2*r^2*acos(d2/(2*d*r))-1/2*sqrt(t);
elseif d > 2*r
A = 0;
else % d < r
A = pi*r^2;
end

カテゴリ

タグ

質問済み:

2014 年 6 月 4 日

回答済み:

2014 年 6 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by