Speed up frames per second
Afficher commentaires plus anciens
I'm trying to create a video/animation using a large amount of data. I have currently collated all 'marker' points and joined them using plot3, but I want to speed up the animation, as it's really slow. I have tried to create a video, but it kept appearing as empty for some reason?
Here is a sample of my code:
for i = 1:1033
RPtoT = [RASIS(i,:); RT2(i,:); RT3(i,:)];
idx = [1 2 3 1];
plot3(RPtoT(idx,1), RPtoT(idx,2), RPtoT(idx,3), '-o', 'Color', 'g');
axis equal
hold on
LPtoT = [LASIS(i,:); LT0(i,:); LT1(i,:)];
idx = [1 2 3 1];
plot3(LPtoT(idx,1), LPtoT(idx,2), LPtoT(idx,3), '-o', 'Color', 'g');
RT = [RT0(i,:); RT1(i,:); RT2(i,:); RT3(i,:)];
idx = [1 2 3 1 4 2 3 4];
plot3(RT(idx,1),RT(idx,2),RT(idx,3),'-o', 'Color', 'g');
LT = [LT0(i,:); LT1(i,:); LT2(i,:); LT3(i,:)];
idx = [1 2 3 1 4 2 3 4];
plot3(LT(idx,1),LT(idx,2),LT(idx,3),'-o', 'Color', 'g');
hold off
Mod = figure(1);
fighandle = gcf();
F = getframe(i);
end
I've tried using the movie function but I haven't noticed it doing anything since I added it to my code.
n = [1, 1000, 10:1000]
movie(F(i),n, 200)
Please bear in mind I'm not an experienced Matlab user, I'm still relatively new. Any help would be much appreciated! Thanks in advance!
5 commentaires
darova
le 30 Juin 2020
try gif animation
Voss
le 30 Juin 2020
A few observations:
Your code seems to always plot in figure 1, but it is calling getframe on figure i, for i = 1:1033.
The variable F is overwritten each time the loop executes. I imagine you want to collect all the frames, not just the last one.
The second argument to movie is the number of times to play the movie (n), so I don't know why it would not be a scalar or what MATLAB does with non-scalar n.
A few questions: Is the call to movie just after the for loop? Does this code run as written? Does it produce an empty animation or does it produce a slow animation (maybe the slow animation you refer to is the plotting loop running as the plots are created)?
You might try replacing the last three lines inside the for loop with the following:
F(i) = getframe(); % getframe defaults to current axes
And try playing the movie like this:
movie(F,1,200); % I don't know whether 200 fps is too fast (seems pretty fast).
% Maybe 30 fps would be better to be able to see the plots change.
MADRobot
le 2 Juil 2020
Voss
le 2 Juil 2020
I'm not sure. What does the error say?
Adam Danz
le 2 Juil 2020
@MADRobot, always include the entire error message when reporting an error.
When there is no input to getframe() it uses the current axes: getframe(gca).
If there is no figure, it will create one.
I'm guessing that the error is either an indexing error with F(i) or the error is unrelated to this line.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Animation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!