31 views (last 30 days)

I have 3 lines y=0,y=-6,y=-14 and have this points in the y=0

xs =[10.9412 17.6187 32.3200 77.3532]

ys=[ 0 0 0 0]

on y= -6 i have these points

xrefraction =[2.1838 3.4641 6.0000 10.3923]

all y is -6

xrefraction1 =[8.7573 14.1546 26.3200 66.9608]

all y is -6

on this line y=-14 I have

xreflecttion =[5.4706 8.8093 16.1600 38.6766]

all y is -14

First i want to plot the three lines y=,y=-l,y=- 14 then linesegmentes from point (0,0) to every point on the line y=-6 (with

xreflecttion =[5.4706 8.8093 16.1600 38.6766]

and all y is -6, and then line-segments from previous points to the corresponding points points on y=-14 with xreflecttion as x coordinates and again from these points to the corresponding points on the y=-6 with xrefraction1 vector as x coordinates and again from this points to the corresponding points on the line y=0 with xs vector as x coordinates . it as actually a rates that get refracted on the first layer y=-6 and reflected on the layer y=-14 to to again the layer y=-6 and so refracted to the surface y=0.

I tried but failed and i dont know if it is possible to matrices here.

here is what I did but i am getting extra lines h1=6 h2=8 vp1=5.4; vp2=6; alpha1=[20 30 45 60] a1=h1./cosd(alpha1) % fra snill's law beta1=asind((vp2/vp1)*sind(alpha1)) a2=h2./cosd(beta1) %b x=[0 48.4974]; y=[0 0]; plot(x,y) hold on; y1=[-6 -6]; plot(x,y1) hold on; y2=[-14 -14]; plot(x,y2) % x1=h1.*tand(alpha1) x2=h2.*tand(beta1) % x3=x2 x4=x1 % Xcorrdinates of refraction ponit is xrefraction=x1 %xcoordinates of reflaction point is xreflecttion=x1+x2 %Xcorrdinates of the second refraction ponit is

xrefraction1=x1+x2+x3 % xcoordinates of intersaction point of refracted ray with the surface line point is xs=x1+x2+x3+x4 % plotting we need x and y coordinates of those points X=[0 2.1838 0 3.4641 0 6.0000 0 10.3923] Y=[0 -h1 0 -h1 0 -h1 0 -h1 ] plot(X,Y) hold on ; %plot([2.1838 5.4706 ],[-h1,-(h1+h2)]) %hold on; %plot([ 5.4706 8.0073],[-(h1+h2),-h1]) %hold on %plot([ 8.0073 10.1912 ],[-h1,0])

plot([2.1838 5.4706 3.4641 8.8093 6.0000 16.1600 10.3923 38.6766],[-h1 -(h1+h2) -h1 -(h1+h2) -h1 -(h1+h2) -h1 -(h1+h2)]) hold on; plot([5.4706 8.7573 8.8093 14.1546 16.1600 26.3200 38.6766 66.9608],[-h1 -(h1+h2) -h1 -(h1+h2) -h1 -(h1+h2) -h1 -(h1+h2)])

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 3 Comments

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/363853-plot-line-segments-on-the-same-plot#comment_498940

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/363853-plot-line-segments-on-the-same-plot#comment_498940

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/363853-plot-line-segments-on-the-same-plot#comment_498951

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/363853-plot-line-segments-on-the-same-plot#comment_498951

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/363853-plot-line-segments-on-the-same-plot#comment_499097

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/363853-plot-line-segments-on-the-same-plot#comment_499097

Sign in to comment.