How can I remove the lines that are not in the cross section of the annulus?

1 visualización (últimos 30 días)
% Declare experimental variables
R1=75; % inner radius
R2=150; % outer radius of pipe cross-section
N=4; % number of devices
% Create arrays and internal variables
r=linspace(R1,R2,200); % array of radial points for temp data
theta=0:360; % array of angles for temp data
alpha=360/N; % spacing for devices
alpha_ar=round([0:alpha:359]); % array of angles for outter devices in R2
alpha_ar2=round([alpha/2:alpha:359]); % array of angles for inner devices in R1
% Mark devices
for d=1:length(alpha_ar)
for f=1:length(alpha_ar2)
x1=R1*cosd(alpha_ar2(d));
y1=R1*sind(alpha_ar2(d));
plot(x1,y1,'rd','MarkerSize',1,'LineWidth',4);
x2=R2*cosd(alpha_ar(f));
y2=R2*sind(alpha_ar(f));
plot(x2,y2,'rd','MarkerSize',1,'LineWidth',4);
end
end
for i=1:length(alpha_ar)
for k=1:length(alpha_ar2)
alpha1=alpha_ar(i); % i = index for alpha1 (device angle)
alpha3=alpha_ar2(k);
j=1; % initialize j, the index for alpha2
while j<=length(alpha_ar)
if j==i % i and j reference different devices...
j=j+1; % if i=j then increment j again
end
if j<=length(alpha_ar)
alpha2=alpha_ar(j); % j = index for alpha2 (device angle)
end
x=[R2*cosd(alpha_ar(i)),R2*cosd(alpha_ar(j)),R1*cosd(alpha_ar2(k)),R1*cosd(alpha_ar2(k))]; % x values of US devices
y=[R2*sind(alpha_ar(i)),R2*sind(alpha_ar(j)),R1*sind(alpha_ar2(k)),R1*sind(alpha_ar2(k))]; % y values of US devices
figure(1);
% add lj line to temperature profile
hold on;
line(x,y,'color','red');
j=j+1; % increment to next transducer
if j==length(alpha_ar) && j==i % increment j again after last
j=j+1; % tao to break out of loop
end
end
end
end
  4 comentarios
Rik
Rik el 3 de Ag. de 2020
Question body recovered from Google cache:
% Declare experimental variables
R1=75; % inner radius
R2=150; % outer radius of pipe cross-section
N=4; % number of devices
% Create arrays and internal variables
r=linspace(R1,R2,200); % array of radial points for temp data
theta=0:360; % array of angles for temp data
alpha=360/N; % spacing for devices
alpha_ar=round([0:alpha:359]); % array of angles for outter devices in R2
alpha_ar2=round([alpha/2:alpha:359]); % array of angles for inner devices in R1
% Mark devices
for d=1:length(alpha_ar)
for f=1:length(alpha_ar2)
x1=R1*cosd(alpha_ar2(d));
y1=R1*sind(alpha_ar2(d));
plot(x1,y1,'rd','MarkerSize',1,'LineWidth',4);
x2=R2*cosd(alpha_ar(f));
y2=R2*sind(alpha_ar(f));
plot(x2,y2,'rd','MarkerSize',1,'LineWidth',4);
end
end
for i=1:length(alpha_ar)
for k=1:length(alpha_ar2)
alpha1=alpha_ar(i); % i = index for alpha1 (device angle)
alpha3=alpha_ar2(k);
j=1; % initialize j, the index for alpha2
while j<=length(alpha_ar)
if j==i % i and j reference different devices...
j=j+1; % if i=j then increment j again
end
if j<=length(alpha_ar)
alpha2=alpha_ar(j); % j = index for alpha2 (device angle)
end
x=[R2*cosd(alpha_ar(i)),R2*cosd(alpha_ar(j)),R1*cosd(alpha_ar2(k)),R1*cosd(alpha_ar2(k))]; % x values of US devices
y=[R2*sind(alpha_ar(i)),R2*sind(alpha_ar(j)),R1*sind(alpha_ar2(k)),R1*sind(alpha_ar2(k))]; % y values of US devices
figure(1);
% add lj line to temperature profile
hold on;
line(x,y,'color','red');
j=j+1; % increment to next transducer
if j==length(alpha_ar) && j==i % increment j again after last
j=j+1; % tao to break out of loop
end
end
end
end

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 22 de Jul. de 2020
figure(1);
% add lj line to temperature profile
hold on;
for ii=0:1
[P1,P2]=deal([x(1+ii);y(1+ii)], [x(2+ii);y(2+ii)]);
fun=@(t) norm(t*P1+(1-t)*P2);
[~,R]=fminbnd(fun,0,1);
if R<R1; continue; end
line([P1(1),P2(1)],[P1(2),P2(2)],'color','red');
end
  3 comentarios
Cnell
Cnell el 22 de Jul. de 2020
If you have time, could you explain how this works?
Matt J
Matt J el 22 de Jul. de 2020
Editada: Matt J el 22 de Jul. de 2020
These lines
fun=@(t) norm(t*P1+(1-t)*P2);
[~,R]=fminbnd(fun,0,1);
find the distance R of the line segment [P1,P2] to the origin. Based on that, you can test whether the line segment remains within the annulus.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Mobile Fundamentals en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by