필터 지우기
필터 지우기

USING FOR LOOP TO PLOT SEVERAL LINES

조회 수: 1 (최근 30일)
F.O
F.O 2017년 11월 2일
편집: F.O 2017년 11월 2일
L=[4:2:20];
%X coordintates for reflaction point x3=L/2;
%Y coordinates for reflection point IS -5
%X coordinate for rays coming back to the surface (y=0 line) is L and all y is 0
First there are rays that goes from point (0,0) to evrey point on the line y=-5 with L/2 as x coordinates and then from these points rays goes back to the line y=0 with L as x coordinate
I did this
X=[0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10;2 4 3 6 4 8 5 10 6 12 7 14 8 16 8 18 10 20];
Y=[0 -5 0 -5 0 -5 0 -5 0 -5 0 -5 0 -5 0 -5 0 -5 ;-5 0 -5 0 -5 0 -5 0 -5 0 -5 0 -5 0 -5 0 -5 0] ;
plot(X,Y)
title('Ray over a halfspace')
I have plotetd this using matrix but I am required to plot it using for loop command which I cant here !! could anyone thankfully help me out?
  댓글 수: 1
KL
KL 2017년 11월 2일
How should your output look like?

댓글을 달려면 로그인하십시오.

채택된 답변

KL
KL 2017년 11월 2일
something like this?
plot(X(:),Y(:))
  댓글 수: 4
KL
KL 2017년 11월 2일
hold on
for k = 1:size(X,2)
plot(X(:,k),Y(:,k));
end
F.O
F.O 2017년 11월 2일
L=[4:2:20];
%X coordintates for reflaction point x3=L/2; %Y coordinates for reflection point IS -5
%X coordinate for rays coming back to the surface (y=0 line) is L and all y are 0 here
First there are rays that goes from point (0,0) to evrey point on the line y=-5 with L/2 as x coordinates and then from these points rays goes back to the line y=0 with L as x coordinate
We shouldn't be using the matrix i written in the original question because that was not what required from me . anyway the script you wrote is giving a warning message (Warning: The figure is too large for the page and will be cut off. Resize the figure, adjust the output size by setting the figure's PaperPosition property, use the 'print' command with either the '-bestfit' or '-fillpage' options, or use the 'Best fit' or 'Fill page' options on the 'Print Preview' window. )

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by