pretty good, Thanks!
update objects' coordinate of the same plot !!!!!!!!!!!!!!!!!!!
조회 수: 1(최근 30일)
표시 이전 댓글
I am trying to plot the changing coordinate of two objects and i wasn't successful yet. So, i was wondering if someone can give me a help. To make it clear the situation look like this:
assume following two objects
function obj = updateGraph(array_obj)
It doesn't work since for each call of update a new plot is been generated. How can I do to just update coordinate on the same graph?
댓글 수: 2
Sven 2013년 8월 30일
Let's just go with one object first for simplicity:
Here's the contents of the user1 class:
classdef user1 < handle
methods (Static = true)
obj = evnt.AffectedObject;
obj.coordinatePlotHandle = plot(obj.coordinate(:,1),obj.coordinate(:,2));
set(obj.coordinatePlotHandle, 'XData', obj.coordinate(:,1), 'YData', obj.coordinate(:,2))
Now you can make a user1 object:
U = user1
Now you can tell it what should happen after its coordinate is updated:
Now you can update its coordinate(s).
U.coordinate = [1 1; 2 4]
U.coordinate = rand(5,2)
You'll notice that the first time its coordinate was set, the event was triggered and a plot was made, with the plot handle being retained and stored in U.coordinatePlotHandle. The next time the coordinate is set, that plot handle is simply updated.
Does that help answer your question?
댓글 수: 0
Find more on Graphics Object Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!