필터 지우기
필터 지우기

how to change the direction of this code from right falling into left to left falling into right

조회 수: 30 (최근 30일)

답변 (2개)

Naga
Naga 2024년 8월 21일 14:51
편집: Naga 2024년 8월 21일 15:29
Hi Lior,
To change the direction of the falling dots from left-to-right to right-to-left, the initial plot position is shifted from (10, 10) to (0, 10) to start from the left. The loop is modified to iterate from 1 to 9 instead of 9 to 1, and the y-coordinate in the plot function is adjusted to 10-y. Please find the modified code below:
plot(0, 10, 'r.', 'markersize', 40)
axis([-1, 11, -1, 11])
for y = 1:9
plot(y,10-y, 'r.', 'markersize', 40)
axis([-1, 11, -1, 11])
pause(0.3)
end
  댓글 수: 3
lior
lior 2024년 8월 21일 15:13
more precisly, from (0,10) on the axis to let's say (1,0) or (1,1)
Naga
Naga 2024년 8월 21일 15:26
편집: Naga 2024년 8월 21일 15:27
I realized I misunderstood your question, so I've revised my response accordingly.

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


Voss
Voss 2024년 8월 21일 14:54
figure
x = 1:10;
y = 10:-1:1;
for ii = 1:numel(x)
plot(x(ii),y(ii),'r.','markersize',40)
axis([-1,11,-1,11])
pause(0.3)
end
  댓글 수: 1
Voss
Voss 2024년 8월 21일 14:57
Another option:
x = 1:10;
y = 10:-1:1;
figure
ax = gca();
h = line(ax,'Color','r','Marker','.','MarkerSize',40);
set(ax,'XLim',[-1 11],'YLim',[-1 11])
for ii = 1:numel(x)
set(h,'XData',x(ii),'YData',y(ii))
pause(0.3)
end

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

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by