Is there a solution to use "circcirc" with continuous variable as radius?

Hello, I am trying to implement trilateration algorithm and I am using "circcirc" command to find intersections of the circles.
My problem is: I need to find intersections of circles, which changes their radius every step but they have the same centers. Is it possible without re-writing the command or with another command?
This is my code:
Center1=[0.75,5];
Center2=[6.98,4.31];
Center3=[3.46,1.48];
radii1=[1; 3; 4];
radii2=[2.5; 3; 2.3];
radii3=[3; 1; 5];
[x_intersection1_2,y_intersection1_2] = circcirc(Center1(:,1),Center1(:,2),radii1,Center2(:,1),Center2(:,2),radii2);
[x_intersection1_3,y_intersection1_3] = circcirc(Center1(:,1),Center1(:,2),radii1,Center3(:,1),Center3(:,2),radii3);
[x_intersection2_3,y_intersection2_3] = circcirc(Center2(:,1),Center2(:,2),radii2,Center3(:,1),Center3(:,2),radii3);

 Respuesta aceptada

Hi Miro,
You may want to use for or while loops. Please find description here. The exact code would vary depending on which radius you want to change at what time.

6 comentarios

Hello Pawel,
I want to change all the radii at each next iteration. Now I tried this, but it gives me mistake:
Center1=[0.75,5];
Center2=[6.98,4.31];
Center3=[3.46,1.48];
radii1=[1, 3, 4];
radii2=[2.5, 3, 2.3];
radii3=[3, 1, 5];
x1_2=zeros(1,4);
y1_2=zeros(1,4);
x1_3=zeros(1,4);
y1_3=zeros(1,4);
x2_3=zeros(1,4);
y2_3=zeros(1,4);
for n = 2:3
[x1_2(n),y1_2(n)] = circcirc(Center1(:,1),Center1(:,2),radii1(n),Center2(:,1),Center2(:,2),radii2(n));
[x1_3(n),y1_3(n)] = circcirc(Center1(:,1),Center1(:,2),radii1(n),Center3(:,1),Center3(:,2),radii3(n));
[x2_3(n),y2_3(n)] = circcirc(Center2(:,1),Center2(:,2),radii2(n),Center3(:,1),Center3(:,2),radii3(n));
end
Hi Miro,
I am not sure why you getting this error. As a solution I propose assigning the output of function to temporary variables a,b,c and then assigning it to actual variables, please find code below.
Center1=[0.75,5];
Center2=[6.98,4.31];
Center3=[3.46,1.48];
radii1=[1, 3, 4];
radii2=[2.5, 3, 2.3];
radii3=[3, 1, 5];
x1_2=zeros(1,4);
y1_2=zeros(1,4);
x1_3=zeros(1,4);
y1_3=zeros(1,4);
x2_3=zeros(1,4);
y2_3=zeros(1,4);
for n = 2:3
a = circcirc(Center1(:,1),Center1(:,2),radii1(n),Center2(:,1),Center2(:,2),radii2(n));
x1_2(n)=a(1);
y1_2(n)=a(2);
b = circcirc(Center1(:,1),Center1(:,2),radii1(n),Center3(:,1),Center3(:,2),radii3(n));
x1_3(n)=b(1);
y1_3(n)=b(2);
c = circcirc(Center2(:,1),Center2(:,2),radii2(n),Center3(:,1),Center3(:,2),radii3(n));
x2_3(n)=c(1);
y2_3(n)=c(2);
end
Thanks a lot for your help. That is perfect! :)
No actually it is not, now i see. It gives me just 1 coordinate for X and 1 for Y. But the circles have 2 intersections. Still something missing :/
yes, I made a mistake regarding the number of outputs of function. x and y are now 2x3 matrix where each row is a different coordinate and each column different radius. Let me know whether it works now.
Center1=[0.75,5];
Center2=[6.98,4.31];
Center3=[3.46,1.48];
radii1=[1, 3, 4];
radii2=[2.5, 3, 2.3];
radii3=[3, 1, 5];
%initialize them as 2 by 3 rather than 1 by 4
x1_2=zeros(2,3);
y1_2=zeros(2,3);
x1_3=zeros(2,3);
y1_3=zeros(2,3);
x2_3=zeros(2,3);
y2_3=zeros(2,3);
for n = 1:3
[x1_2(:,n),y1_2(:,n)] = circcirc(Center1(:,1),Center1(:,2),radii1(n),Center2(:,1),Center2(:,2),radii2(n));
[x1_3(:,n),y1_3(:,n)] = circcirc(Center1(:,1),Center1(:,2),radii1(n),Center3(:,1),Center3(:,2),radii3(n));
[x2_3(:,n),y2_3(:,n)] = circcirc(Center2(:,1),Center2(:,2),radii2(n),Center3(:,1),Center3(:,2),radii3(n));
end
Thanks a lot. Yes it is working this time perfectly.
I have fixed it by the way bellow but your approach is much more simple.
[c,c1] = circcirc(Center2(:,1),Center2(:,2),radii2(n),Center3(:,1),Center3(:,2),radii3(n));
x2_3(1,n)=c(1);
y2_3(1,n)=c1(1);
x2_3(2,n)=c(2);
y2_3(2,n)=c1(2);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Software Development Tools en Centro de ayuda y File Exchange.

Preguntada:

el 10 de Ag. de 2016

Comentada:

el 10 de Ag. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by