Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: I have a question about gui
Date: Sun, 30 Nov 2008 10:47:02 +0000 (UTC)
Organization: PhysioSonics Inc
Lines: 80
Message-ID: <ggtqv6$nbi$1@fred.mathworks.com>
References: <ggjvea$sfi$1@fred.mathworks.com> <gglqam$1c0$1@fred.mathworks.com> <ggtn24$44i$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1228042022 23922 172.30.248.38 (30 Nov 2008 10:47:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 30 Nov 2008 10:47:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1129061
Xref: news.mathworks.com comp.soft-sys.matlab:503889


"J.J. hamin" <JJham2142@gmail.com> wrote in message <ggtn24$44i$1@fred.mathworks.com>...
> Very Very Thanks for your answer.
> 
> It's helpful!
> 
> but, I can't make program in a concrete way.
> 
> So, Could you sent me a example source code that was mentioned your answer?
> 
> my email is JJham2142@gmail.com


function hOut = moveObjectWithTimer
% This function randomly creates 'dots' and moves them across the screen

global h

h.figure = figure;

h.axes = axes('XLim', [0 10], ...
    'YLim', [0 10]);   

h.line = [];

h.timer = timer('ExecutionMode', 'fixedrate', ...
    'Period', 1, ...
    'TimerFcn', @moveObject);

start(h.timer);

hOut = h;

function moveObject(tObj, eventdata)

global h

% Move objects
for i=1:length(h.line)
    XData = get(h.line(i), 'XData');
    YData = get(h.line(i), 'YData');    
    XData = XData - 1;
    YData = YData - 1;
    set(h.line(i), 'XData', XData, ...
        'YData', YData);
end

% Randomly create a new object, on average every nPeriods
nPeriods = 5;
r = randi(nPeriods, 1);
if r == 1
    hObj = createObject;
    h.line = [h.line hObj];
end

% Delete objects that have reached lhs of axes
hLineTemp = h.line;
for i=1:length(h.line)
    XData = get(h.line(i), 'XData');
    YData = get(h.line(i), 'YData');    
    if XData==-1 && YData==-1
        delete(hLineTemp(i))
        hLineTemp(i)=[];
    end
end
h.line = hLineTemp;


function hObj = createObject

global h

hObj = line('Parent', h.axes, ...
    'XData', 10, ...
    'YData', 10, ...
    'Marker', 'o', ...
    'MarkerFaceColor', [0 0 0], ...
    'LineStyle', 'none');
        
% [EOF]