Thursday, 8 December 2011

Matlab Animation Plot | Matlab Moving Object Plots | Drawnow hold on Matlab Command Example

While Plot the data's on matlab you not see the figure window.You only sea the after plot the data.If you use drawnow command you have easy to see while plot the data's.here we give some example for plot the data with animation.Here we use plot data with style of star '*' with hold on and drawnow functions command.
  1. hold on used for continuous plot the data with update the current data axis.
  2. drawnow command used for No refresh the current window screen.
Below example mainly helpful to you for Matlab animation plot.Here we randomly generate continuous position and pot the data's for 100 iterations with some delay.Matlab pause command used for delay operation.

clc
clear all
close all
warning off
x = 1;
y =1;
figure;
for iter = 1:150
plot(x,y,'*');
hold on
drawnow
y = y+1;
randnum_chk = round(rand*2);
if randnum_chk==1
x = x+1;
else
x = x-1;
end
if x<=0
x =x+1;
end
pause(0.01);
axis([0 150 0 150]);
end

In above program output as follows.



Kindly Bookmark and Share it:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...