I would like to create an animation to demonstrate LDPC coding which is based on Sum-Product Algorithm
So far I have created a graph which shows the connections betw
I believe the best way to learn is by example. So I suggest you look at the demo lorenz
which comes with MATLAB:
edit lorenz
For other cool animations, look for orbits.m
and swinger.m
demos part of Cleve Moler's book: Experiments with MATLAB
I show here a simple animation of a point moving along a circular path. The hold idea boils down to using EraseMode
set to xor
, and updating XData
and YData
of the point for each iteration:
%# coordinates
t = (0:.01:2*pi)'; %# 'fix SO syntax highlight
D = [cos(t) -sin(t)];
%# setup a figure and axis
hFig = figure('Backingstore','off', 'DoubleBuffer','on');
hAx = axes('Parent',hFig, 'XLim',[-1 1], 'YLim',[-1 1], ...
'Drawmode','fast', 'NextPlot','add');
axis(hAx, 'off','square')
%# draw circular path
line(D(:,1), D(:,2), 'Color',[.3 .3 .3], 'LineWidth',1);
%# initialize point
h = line('XData',D(1,1), 'YData',D(1,2), 'EraseMode','xor', ...
'Color','r', 'marker','.', 'MarkerSize',50);
%# init text
hTxt = text(0, 0, num2str(t(1)), 'FontSize',12, 'EraseMode','xor');
i=0;
while true
i = rem(i+1,numel(t)) + 1; %# circular increment
set(h,'XData',D(i,1), 'YData',D(i,2)) %# update X/Y data
set(hTxt,'String',num2str(t(i))) %# update angle text
drawnow %# force refresh
if ~ishandle(h), return; end %# in case you close the figure
end
For a detailed explanation of the parameters used (EraseMode
, Backingstore
, DoubleBuffer
, ..), refer to this animation guide
From the documentation for comet.m
t = 0:.01:2*pi;
x = cos(2*t).*(cos(t).^2);
y = sin(2*t).*(sin(t).^2);
comet(x,y);