how can i draw rectangle with line command?
and i wanna it moves
please help

 채택된 답변

Walter Roberson
Walter Roberson 2016년 2월 27일

0 개 추천

high = 42; %example
wide = 65; %example
x0 = 0;
y0 = 0;
maxx = 500;
yamp = 300;
pos = [x0 y0 wide high];
r = rectangle('Position', pos);
xlim([0 x0+maxx+wide]);
ylim([0 y0+yamp+high]);
axis equal
hold on;
for K = 0 : 5 : maxx
x = x0 + K;
y = abs(yamp * sin(x));
pos = [x y wide high];
set(r, 'Position', pos);
pause(0.1)
end

댓글 수: 4

Or did you mean you wanted to use line() instead of rectangle() ?
ismail uzun
ismail uzun 2016년 2월 27일
more simle i wanna this shape move x axis but it must made xor command
x = [2,2,12]; y= [2,7];
line([x(1), x(2)], [y(1), y(2)], 'Color', 'b', 'LineWidth', 3); line([x(1), x(3)], [y(2), y(2)], 'Color', 'b', 'LineWidth', 3); line([x(3), x(3)], [y(2), y(1)], 'Color', 'b', 'LineWidth', 3); line([x(3), x(1)], [y(1), y(1)], 'Color', 'b', 'LineWidth', 3);
ylim([0, 50]);
xlim([0, 50]);
grid on;
The moving is the easy part. Whether you can do it with xor depends upon which MATLAB version you are using. Drawing with xor was dropped as of R2014b.
Is it possible that your actual situation involves an image that your rectangle is to appear to move over, and you have been instructed to use xor in your implementation of that?
ismail uzun
ismail uzun 2016년 2월 28일
thanks bro

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

질문:

2016년 2월 27일

댓글:

2016년 2월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by