Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating an animated plot

Status
Not open for further replies.

ashwinsamant

Electrical
Mar 22, 2008
1
Hello guys,

Here is the situation i am in.. I have stored like 20 values of X and Y Position from time 1sec to 20 sec in an excel sheet and I want my code to extract those and plot them for each time.and the plot should look animated. The best way to describe it that there is a car moving from from time 1 to 20 secs and i want to have its trajectory. Now i am able to do all that. I am more interested getting graphics..like say a huge ball represents that car and the ball moves every sec along those values..Please help as its urgent..

Thanks
Ashes.cfg

here is the code i have developed.. as u can see i am able to get the plot but I want a ball or any object to follow that path(ball represents my car in motion)..also attaching my values file

Code:
clc;
clear all;


num = xlsread('Value.xls')

Time = num(:,1); 
% count = num of rows in the initial matrix - num or Time
%Time(count)
count=length(Time);

X=num(1,2);
Y=num(1,3);

hold on;

p = plot(X,Y)
axis([-10000 10000 -10000 10000])

for iCount = 2:count
    X(iCount)=num(iCount,2);
    %X
    Y(iCount)=num(iCount,3);
    %Y
  
    % Change coordinates
    set(p,'XData',X,'YData',Y);

%     refreshdata
%     drawnow
    pause(.5)
end
 
Replies continue below

Recommended for you

Take a look at the "erasemode" property of the plot. I don't have ML to hand right now, but I think "xor" might be what you want.

- Steve
 
change your p=plot(x,y) to

p=plot(NaN,Nan,'O')

then do the XData, YData update.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor