plot line segments on the same plot

2 Ansichten (letzte 30 Tage)
F.O
F.O am 28 Okt. 2017
Bearbeitet: Cedric am 31 Okt. 2017
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)])
  3 Kommentare
Rik
Rik am 30 Okt. 2017
I think you copied the wrong link, Cedric ;)
If you want to plot several lines, you can use hold on, supply multiple vectors to plot, or separate the parts with NaN (which plot ignores).
Cedric
Cedric am 31 Okt. 2017
Thank you Rik! I edited the link so we don't get stuck in some infinite loop clicking and clicking again ;-)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by