create video of position from matrix
Show older comments
I would like to plot the evolution of the positions of the nodes of my graph by extracting such informations from a matrix. I have tried with the following code:
nodesmatrix1=[100.930486523955,100.930575750737,100.930665005716,100.930754288889;...
0.537217125673953,0.537268640710124,0.537320172025868,0.537371719619598;...
0,0,0,0;...
-50,-50,-50,-50;...
87.6769342598990,87.6770372900756,87.6771403528114,87.6772434481033;...
0,0,0,0;...
-50,-50,-50,-50;...
-86.6025000000000,-86.6025000000000,-86.6025000000000,-86.6025000000000;...
0,0,0,0;...
-86.8313497413550,-86.8331653236005,-86.8349807356126,-86.8367959772504;...
50.8442720217766,50.8412459247854,50.8382199043914,50.8351939608639;...
202.668269119694,202.667265160646,202.666261247557,202.665257380501;...
0.313749463634742,0.317367162195871,0.320984737502106,0.324602189246993;...
-100.083107035647,-100.083114813157,-100.083122465259,-100.083129991967;...
202.668270199404,202.667266238431,202.666262323417,202.665258454434;...
87.4480844077347,87.4463715232573,87.4446586199985,87.4429456981209;...
50.8504867629172,50.8536751827095,50.8568634493359,50.8600515625364;...
202.668269910080,202.667265949606,202.666262035091,202.665258166609];
edge = [1 2;2 3;3 1;1 4;2 5;3 6];
type = [1; 1; 1; -1; -1; -1];
structure = VideoWriter('structure.avi');
open(structure);
for i = 1:4
EdgeTable = table(edge,type, ...
'VariableNames',{'EndNodes','type'});
structure=graph(EdgeTable);
nodestep=nodesmatrix1(:,i);
nodestepmatrix=[nodestep(1:3:length(nodestep))'; nodestep(2:3:length(nodestep))'; nodestep(3:3:length(nodestep))'];
p=plot(structure,'XData', nodestepmatrix(1,:), 'YData', nodestepmatrix(2,:),'ZData',nodestepmatrix(3,:));
frame = getframe(gcf);
writeVideo(structure,frame);
end
close(structure);
But it doesn't work. I obtain only the plot of the last column of nodesmatrix1.
What is wrong?
Accepted Answer
More Answers (0)
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!