Question on Plotting from Cell Array
Afficher commentaires plus anciens
Hi guys,
I have a 1000*10 cell array, where each cell is a 1*3 3D coordinate. A segment of this cell array is shown below:

The rows represent time in second, and each column represent location of an object, so each cell is an object's coordinate in space at a given second. There are 10 columns for 10 objects, and 1000 rows for 1000 seconds. I wish to create an animation of all these objects' locations in space from 1s to 1000s: how would I do that? The objects can just be scatter points in a MATLAB 3D plot. Thank you for your help!
GZ
Réponse acceptée
Plus de réponses (2)
Matt J
le 24 Août 2019
Points=reshape( [CellArray{:}] ,3,[],10); %
for i=1:1000
X=Points(1,i,:);
Y=Points(2,i,:);
Z=Points(3,i,:);
scatter3(X(:),Y(:),Z(:)); drawnow
end
dpb
le 24 Août 2019
Dereference the cell array with the curlies "{}"
for i=1:size(CA,2)
scatter3(CA{i}(:,1),CA{i}(:,2),CA{i}(:,3))
if i==1,hold on, end
end
if the cell array is CA the above will put all on a single axis with cycled colors. Insert additional arguments for size or varied color map or whatever--"salt to suit".
Or, could create subplots of additional figure each pass, all just depends on the effect you're after.
Catégories
En savoir plus sur Animation dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!