2010-05-08 67 views
1

我想創建一個動畫來演示其基於Sum-Product AlgorithmMatlab仿真:點(符號)從開始點移動到終點和背部

到目前爲止,我已經創建了一個圖表LDPC編碼,顯示連接在符號節點(左側)和奇偶校驗節點(右側)之間alt text http://img29.imageshack.us/img29/9780/ldpc.jpg,並且想要動畫從符號到奇偶校驗節點並返回的點。

function drawVertices(H) 
hold on; 
nodesCount = size(H); 
parityNodesCount = nodesCount(1); 
symbolNodesCount = nodesCount(2); 
symbolPoints = zeros(symbolNodesCount, 2); 
symbolPoints(:, 1) = 0; 
for i = 0 : symbolNodesCount - 1 
    ji = symbolNodesCount - i; 
    scatter(0, ji) 
    symbolPoints(i + 1, 2) = ji; 

end; 
parityPoints = zeros(parityNodesCount, 2); 
parityPoints(:, 1) = 10; 
for i = 0 : parityNodesCount - 1 
    ji = parityNodesCount - i; 
    y0 = symbolNodesCount/2 - parityNodesCount/2; 
    scatter(10, y0 + ji) 
    parityPoints(i + 1, 2) = y0 + ji; 
end; 
axis([-1 11 -1 symbolNodesCount + 2]); 
axis off 

%connect vertices 
d = size(H); 
for i = 1 : d(1) 
    for j = 1 : d(2) 
     if(H(i, j) == 1) 
      plot([parityPoints(i, 1) symbolPoints(j, 1)], [parityPoints(i, 2) symbolPoints(j, 2)]); 
     end; 
    end; 
end; 

所以我想在這裏做什麼是添加另一這需要啓動點(x和y)和終點作爲參數,並激活方法:

下圖是通過執行以下方法繪製沿着顯示的行從開始到結束並返回到行進的圓圈(點)。

我將不勝感激,如果你們中的任何人都可以展示解決方案或建議任何有關matlab仿真的有用教程。

謝謝!

回答

2

我相信最好的學習方式就是舉例。因此,我建議你看一下演示lorenz附帶MATLAB:

edit lorenz 

對於其他動畫,尋找克里夫·莫勒爾的書orbits.mswinger.m演示部分:Experiments with MATLAB


我秀這裏是一個沿圓形路徑移動的點的簡單動畫。保持想法歸結爲使用EraseMode設置爲xor,和更新XData和點每次迭代的YData

%# 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 

對於所使用的參數的詳細說明(DoubleBufferEraseModeBackingstore,..),參閱本animation guide