Animation video from data points, giving error below

3 visualizzazioni (ultimi 30 giorni)
Hi,
I am making the the animation from the data points. but I am gettig the error below, can anyone help me come over this error. Also if anyone can help me recording this data like 1 point for 1 fps that be great. Below is the error and the code I am using.
Error:
Error using VideoWriter/writeVideo (line 414)
Requested 968x1902x3x2184 (11.2GB) array exceeds maximum array size preference. Creation of
arrays greater than this limit may take a long time and cause MATLAB to become
unresponsive.
Error in graphanimation (line 28)
writeVideo(video,F);
Code:
close all; clear all; clc;
%plotting the graph animation
a=readmatrix('pressure_experiement.ods');
x=a(:,7);
y=a(:,11);
curve = animatedline('color','b','Marker','x');
set(gca,'XLim',[0 500],'YLim',[0 90]);
grid on;
title('CircleSide_Awaypoint');
xlabel('Head (mm)');
ylabel('Pressure (mmH2o)');
set(gcf,'Units','normalized','OuterPosition',[0 0 1 1]);
for i=1:length(x)
addpoints(curve,x(i),y(i));
drawnow
F(i)=getframe(gcf)
%pause(0.5)
end
hold all
video = VideoWriter ('away.avi','MPEG-4')
video.FrameRate = 1;
open(video)
writeVideo(video,F);
close(video)

Risposta accettata

Konrad
Konrad il 2 Set 2021
Modificato: Konrad il 2 Set 2021
Hi Muhammad,
it seems that the video you are trying to create is too large to fit into memory. You can either
  1. run the code on a machine with more RAM (like a server); or if such a computer is not available
  2. try to make the figure you are capturing smaller (your frames currently have a resolution of 1902x968 pixels). Change the line
set(gcf,'Units','normalized','OuterPosition',[0 0 1 1]);
to e.g.
set(gcf,'Units','pixels','Position',[0 0 1280 720]);
to get a resolution of 1280x720. If you still get the error, further reduce the resolution.
Best, Konrad
EDIT: --------------------------
If you need the high resolution, another way to reduce memory requirements might be to split the animation into multiple videos (e.g. 10 videos each containing 218 frames or so) and then use a video editing software (e.g. avidemux) to merge videos.

Più risposte (1)

muhammad choudhry
muhammad choudhry il 3 Set 2021
You gave me a perfect advice I was looking for. Thanks alot, I have been using avidemux after failing to merge the videos using matlab code.

Categorie

Scopri di più su Animation in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by