"InterX" gives me TWO coordinates instead of ONE. How can I solve this?
조회 수: 2 (최근 30일)
이전 댓글 표시
I execute this code in the command window:
hold on
grid
axis equal
Q=11;
x1=0;
y1=0;
R=10;
%% %DIBUJO DE LA CIRCUNFERENCIA
%x and y are the coordinates of the center of the circle
%r is the radius of the circle
%0.01 is the angle step, bigger values will draw the circle faster but
caca=2*pi();
ang=linspace(0,caca);
xp=R*cos(ang);
yp=R*sin(ang);
circ=[xp;yp];
plot(xp,yp,'r');
%% %DIBUJO DE LOS RAYOS
anguloo=0;
[r0x,r0y]=coordrecta(x1,y1,Q,anguloo)
r0=[x1 r0x;y1 r0y];
plot(r0(1,:),r0(2,:),'r')
anguloo=10;
[r10x,r10y]=coordrecta(x1,y1,Q,anguloo)
r10=[x1 r10x;y1 r10y];
plot(r10(1,:),r10(2,:),'r')
anguloo=20;
[r20x,r20y]=coordrecta(x1,y1,Q,anguloo)
r20=[x1 r20x;y1 r20y];
plot(r20(1,:),r20(2,:),'r')
anguloo=30;
[r30x,r30y]=coordrecta(x1,y1,Q,anguloo)
r30=[x1 r30x;y1 r30y];
plot(r30(1,:),r30(2,:),'r')
anguloo=40;
[r40x,r40y]=coordrecta(x1,y1,Q,anguloo)
r40=[x1 r40x;y1 r40y];
plot(r40(1,:),r40(2,:),'r')
anguloo=50;
[r50x,r50y]=coordrecta(x1,y1,Q,anguloo)
r50=[x1 r50x;y1 r50y];
plot(r50(1,:),r50(2,:),'r')
anguloo=60;
[r60x,r60y]=coordrecta(x1,y1,Q,anguloo)
r60=[x1 r60x;y1 r60y];
plot(r60(1,:),r60(2,:),'r')
anguloo=70;
[r70x,r70y]=coordrecta(x1,y1,Q,anguloo)
r70=[x1 r70x;y1 r70y];
plot(r70(1,:),r70(2,:),'r')
anguloo=80;
[r80x,r80y]=coordrecta(x1,y1,Q,anguloo)
r80=[x1 r80x;y1 r80y];
plot(r80(1,:),r80(2,:),'r')
anguloo=90;
[r90x,r90y]=coordrecta(x1,y1,Q,anguloo)
r90=[x1 r90x;y1 r90y];
plot(r90(1,:),r90(2,:),'r')
%% %PUNTOS DE CORTE C
c0=InterX(circ,r0);
plot(c0(1,:),c0(2,:),'go');
c10=InterX(circ,r10);
plot(c10(1,:),c10(2,:),'go');
c20=InterX(circ,r20);
plot(c20(1,:),c20(2,:),'go');
c30=InterX(circ,r30);
plot(c30(1,:),c30(2,:),'go');
c40=InterX(circ,r40);
plot(c40(1,:),c40(2,:),'go');
c50=InterX(circ,r50);
plot(c50(1,:),c50(2,:),'go');
c60=InterX(circ,r60);
plot(c60(1,:),c60(2,:),'go');
c70=InterX(circ,r70);
plot(c70(1,:),c70(2,:),'go');
c80=InterX(circ,r80);
plot(c80(1,:),c80(2,:),'go');
c90=InterX(circ,r90);
plot(c90(1,:),c90(2,:),'go');
%% %DIBUJO DE LAS TANGENTES
angulito=0+90;
[t0x2,t0y2]=coordrecta(c0(1),c0(2),3*R,angulito)
t0=[c0(1) t0x2;c0(2) t0y2];
plot(t0(1,:),t0(2,:),'b')
angulito=10+90;
[t10x2,t10y2]=coordrecta(c10(1),c10(2),3*R,angulito)
t10=[c10(1) t10x2;c10(2) t10y2];
plot(t10(1,:),t10(2,:),'b');
angulito=20+90;
[t20x2,t20y2]=coordrecta(c20(1),c20(2),3*R,angulito)
t20=[c20(1) t20x2;c20(2) t20y2];
plot(t20(1,:),t20(2,:),'b')
angulito=30+90;
[t30x2,t30y2]=coordrecta(c30(1),c30(2),3*R,angulito)
t30=[c30(1) t30x2;c30(2) t30y2];
plot(t30(1,:),t30(2,:),'b')
angulito=40+90;
[t40x2,t40y2]=coordrecta(c40(1),c40(2),3*R,angulito)
t40=[c40(1) t40x2;c40(2) t40y2];
plot(t40(1,:),t40(2,:),'b')
angulito=50+90;
[t50x2,t50y2]=coordrecta(c50(1),c50(2),3*R,angulito)
t50=[c50(1) t50x2;c50(2) t50y2];
plot(t50(1,:),t50(2,:),'b')
angulito=60+90;
[t60x2,t60y2]=coordrecta(c60(1),c60(2),3*R,angulito)
t60=[c60(1) t60x2;c60(2) t60y2];
plot(t60(1,:),t60(2,:),'b')
angulito=70+90;
[t70x2,t70y2]=coordrecta(c70(1),c70(2),3*R,angulito)
t70=[c70(1) t70x2;c70(2) t70y2];
plot(t70(1,:),t70(2,:),'b')
angulito=80+90;
[t80x2,t80y2]=coordrecta(c80(1),c80(2),3*R,angulito)
t80=[c80(1) t80x2;c80(2) t80y2];
plot(t80(1,:),t80(2,:),'b')
angulito=90+90;
[t90x2,t90y2]=coordrecta(c90(1),c90(2),3*R,angulito)
t90=[c90(1) t90x2;c90(2) t90y2];
plot(t90(1,:),t90(2,:),'b')
%% %DIBUJO DE LOS ARCOS
mierda=2*pi();
gulo=linspace(0,mierda);
% con CADA punto/arco %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%circulo en c80 (NO DIBUJARLO)
radius=norm(c90-c80);
zentroa=c80;
corx=zentroa(1)+radius*cos(gulo);
cory=zentroa(2)+radius*sin(gulo);
circulu=[corx;cory];
%calculo del punto de interseccion i90
%i90=InterX(circulu,t90);
%plot(i90(1,:),i90(2,:),'bo');
i90=c90;
%calculo del punto de interseccion i80
i80=InterX(circulu,t80);
plot(i80(1,:),i80(2,:),'bo');
%recta i80-c80 recta inicio arco
recti=[c80(1) i80(1);c80(2) i80(2)];
%angulo inicio del arco, recta c80-i80
[angini]=angulodrectav2(recti)
%pasandolo a radianes
rangini=deg2rad(angini);
%recta i90-c80 recta inicio arco
rectf=[c80(1) i90(1);c80(2) i90(2)];
%angulo final del arco, recta c80-i90
[angfin]=angulodrectav2(rectf)
%pasandolo a radianes
rangfin=deg2rad(angfin);
%dibujo del arco
teta = linspace(rangini,rangfin);
xco = zentroa(1)+radius*cos(teta);
yco = zentroa(2)+radius*sin(teta);
plot(xco,yco,'m');
% con CADA punto/arco %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%circulo en c70 (NO DIBUJARLO)
radius=norm(i80-c70);
zentroa=c70;
corx=zentroa(1)+radius*cos(gulo);
cory=zentroa(2)+radius*sin(gulo);
circulu=[corx;cory];
%calculo del punto de interseccion i70
i70=InterX(circulu,t70);
plot(i70(1,:),i70(2,:),'bo');
And as you can see, the Intersec point i70 that Matlab gives me, is a 2x2 matrix. Thtat doesn't make any sense, because i70 is a point, it should be only a 2x1 matrix, with only one coordinates.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/394993/image.png)
However, if I execute in the command window the same code, but the only code needed to calculate i70 replacing all de data (such as c70...etc) by its exact values, as I do here:
mierda=2*pi();
gulo=linspace(0,mierda);
t70=[3.4189 -24.7719;9.3934 19.6540];
radius=3.4814;
zentroa=[3.4189;9.3934]; %c70=[3.4189;9.3934]
corx=zentroa(1)+radius*cos(gulo);
cory=zentroa(2)+radius*sin(gulo);
circulu=[corx;cory];
i70=InterX(circulu,t70); %i70=[0.1475;10.5841]
Matlab gives me i70 as a 2x1 matrix, this is, the correct way of giving me the coordinates of a point:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/394998/image.png)
If theorically is the same data, the same code, why does this happen? How can I solve it?
댓글 수: 2
KSSV
2020년 10월 28일
If you see the 2*2 matrix displays the same values....you can pcik only one using unique.
iwant = unique(i70','rows')'
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!