How can I remove the lines that are not in the cross section of the annulus?
1 view (last 30 days)
Show older comments
% 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 Comments
Rik
on 3 Aug 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
Accepted Answer
Matt J
on 22 Jul 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 Comments
More Answers (0)
See Also
Categories
Find more on MATLAB Mobile Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!