我有关于显示边缘和节点的网络的数据,例如:
edges = ...
[5 7 1;
5 7 2;
5 11 2;
5 7 3;
5 11 3;
5 16 3;
5 7 4;
5 11 4;
5 16 4;
5 21 4];我想根据这些边是如何进化的,得到多个不同的图,因为这些边是长时间观察的结果(例如,一年)。
每个边在不同的时刻发生,因此,我想分别得到这六个不同的情节。
假设,第一个月我看到了这些边缘:
edges = ...
[5 7 1];在第二个月,我看到:
edges = ...
[5 7 2;
5 11 2;];并且每个月都会添加更多的边,直到得到完整的数据集。
编辑
第三列是矩标识符,使用本文(用某些列值过滤矩阵 ),我可以遍历矩阵并获得在图()函数中使用的filtered_edges。
端编辑
简单的方法是创建不同的边缘文件并逐个读取它们,但是是否有一种方法可以用Matlab编程完成呢?
发布于 2016-04-26 22:29:47
有关细节,请参阅mathworks文档。就你的情况而言,给你:
data = rand(6,2);
figure
% You need to somehow fix your axes, so that they don't resize
axis tight manual
ax = gca;
ax.NextPlot = 'replaceChildren';
% Let's record this to file
v = VideoWriter('myAnimation.avi');
v.FrameRate = 10; % slow down the animation
open(v);
loops = size(data,1);
F(loops) = struct('cdata',[],'colormap',[]); % Struct to hold frames
for i = 1:loops
plot(data(1:i,1),data(1:i,2),'*'); % plot what you want in the new frame
drawnow % clear and draw new frame
frame = getframe;
F(i) = frame; % if you want to animate locally you only need this
pause(0.1); % this just slows down locally, can be removed and does NOT influence the saved video
writeVideo(v,frame); % this is only if you want to save to file
end
close(v);https://stackoverflow.com/questions/36874623
复制相似问题