poster
2019-12-10, 20:41
我想创建一个动画来演示基于和积算法的 (http://en.wikipedia.org/wiki/Belief_propagation) LDPC编码
到目前为止,我已经创建了一个图形,该图形显示了符号节点(左)和奇偶校验节点(右)之间的连接alt文本http://img29.imageshack.us/img29/9780/ldpc.jpg (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仿真的有用教程,我将不胜感激。
谢谢!
回答:
我相信最好的学习方法就是以身作则。所以我建议您看一下MATLAB随附的演示lorenz :
edit lorenz 对于其他很酷的动画,寻找orbits.m和swinger.m克里夫·莫勒尔的书的演示部分: 用MATLAB实验 (http://www.mathworks.com/moler/exm/exmfilelist.html)
我在这里展示了一个沿圆形路径移动的点的简单动画。搁置的想法归结为使用设置为xor EraseMode ,并为每次迭代更新该点的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 对于所使用的参数的详细说明( EraseMode , Backingstore , DoubleBuffer ,..),请参见本动画导 (http://www.mathworks.com/support/tech-notes/1200/1204.html#Section%2023)
更多&回答... (https://stackoverflow.com/questions/2794144)
到目前为止,我已经创建了一个图形,该图形显示了符号节点(左)和奇偶校验节点(右)之间的连接alt文本http://img29.imageshack.us/img29/9780/ldpc.jpg (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仿真的有用教程,我将不胜感激。
谢谢!
回答:
我相信最好的学习方法就是以身作则。所以我建议您看一下MATLAB随附的演示lorenz :
edit lorenz 对于其他很酷的动画,寻找orbits.m和swinger.m克里夫·莫勒尔的书的演示部分: 用MATLAB实验 (http://www.mathworks.com/moler/exm/exmfilelist.html)
我在这里展示了一个沿圆形路径移动的点的简单动画。搁置的想法归结为使用设置为xor EraseMode ,并为每次迭代更新该点的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 对于所使用的参数的详细说明( EraseMode , Backingstore , DoubleBuffer ,..),请参见本动画导 (http://www.mathworks.com/support/tech-notes/1200/1204.html#Section%2023)
更多&回答... (https://stackoverflow.com/questions/2794144)