Matlab仿真:点(符号)从开始点移动到终点和背部 [英] Matlab Simulation: Point (symbol) Moving from start point to end point and back
问题描述
我想创建一个动画来演示其基于积算法一LDPC编码>
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 between symbol nodes (left) and parity nodes (right) and would like to animate points travelling from symbol to parity nodes and back.
这个数字是通过执行以下方法得出:
The figure is drawn by executing the following method:
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)和终点作为参数,并以动画从开始旅游圈(点)沿显示的行结束,背法。
So what I would like to do here is to add another method which takes start point (x and y) and end point as arguments and animates a travelling circle (dot) from start to end and back along the displayed lines.
我想AP preciate如果你们任何人都可以展示的解决方案或建议有关MATLAB仿真任何有用的教程。
I would appreciate if anyone of you could show the solution or suggest any useful tutorial about matlab simulations.
感谢您!
推荐答案
我认为最好的学习方法是通过例子。因此,我建议你看一下演示洛伦茨
附带MATLAB:
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
有关其他的酷的动画,找 orbits.m
和 swinger.m
演示克里夫·莫勒尔的书的一部分: rel=\"nofollow\">实验
For other cool animations, look for orbits.m
and swinger.m
demos part of Cleve Moler's book: Experiments with MATLAB
我在这里展示沿圆形路径移动的一个点一个简单的动画。保持想法归结为使用 EraseMode
设置为 XOR
,并更新扩展数据
和 YDATA
:
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
有关使用的参数( EraseMode
,备份存储
, DoubleBuffer <详细解释/ code>,..),请参阅本的动画指南
For a detailed explanation of the parameters used (EraseMode
, Backingstore
, DoubleBuffer
, ..), refer to this animation guide
这篇关于Matlab仿真:点(符号)从开始点移动到终点和背部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!