MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayTo resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Asked by GA optimization on 19 Sep 2013

I want to generate a straight line at bottom of a square and then move to line from bottom side of square to top side of square with a constant speed and want to see in plot at different times, where line exist (visualization).

Thanks

*No products are associated with this question.*

Answer by Azzi Abdelmalek on 19 Sep 2013

Accepted answer

x=[0 10] figure; plot([0 10 10 0 0],[0 0 10 10 0],'r') xlim([0 10]) ylim([0 10]) hold on; for k=0:0.01:10 h=plot(x,[k k]) pause(0.01); delete(h) end

Show 6 older comments

GA optimization on 19 Sep 2013

I want to take different plots/image of line at different location rather than moving line from bottom to top.I mean, I want to show, at time t=0, line is at bottom, then after some time , it is at different position through images,means images for different time.

Azzi Abdelmalek on 19 Sep 2013

x=[0 10] figure; hold on plot([0 10 10 0 0],[0 0 10 10 0],'r') xlim([0 10]) ylim([0 10]) position=3; h=plot(x,[position position])

## 0 Comments