2016-04-26 83 views
0

我有關於一個網絡數據表示邊沿和節點如:你如何繪製隨時間變化的圖形?

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;]; 

而且逐月,更多的邊緣加入,直至完成數據集顯示在上面獲得。

EDIT

第三列是此刻標識符和使用本文(Filter Matrix by some column value )我可以循環通過基質和得到filtered_edges圖中的()函數來使用。

編輯完

最簡單的方法是創建不同的邊緣文件和讀取它們一個接一個,但有沒有辦法用Matlab編程方式做到這一點?

+0

你能詳細說明你正在使用的數據集? – EAA

+0

@EAA - 剛剛添加了更多關於邊緣隨着時間變化的細節。 – lwall

+0

任何理由我的答案不適合你? –

回答

0

查看詳情mathworks documentation。爲你的情況,在這裏你去:

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); 
相關問題