MATLAB online video creation trouble

33 vues (au cours des 30 derniers jours)
Duncan Carlsmith
Duncan Carlsmith le 14 Oct 2025 à 17:54
Commenté : Cris LaPierre le 15 Oct 2025 à 12:15
The following test code runs in 3 seconds natively with v2025a but stalls and never completes in MATLAB online. Any suggestion appreciated.
% Quick animation video test (works in MATLAB Online and Desktop)
clear; close all; clc;
tic
% ---- Output file (timestamped) ----
outdir = 'testvideos';
if ~(exist(outdir,'dir')==7), mkdir(outdir); end
ts = char(datetime('now','Format','yyyyMMdd_HHmmss'));
base = fullfile(outdir, ['ball_line_' ts]);
vidfile = [base '.avi'];
vw = VideoWriter(char(vidfile));
vw.FrameRate = 30;
vw.Quality = 90;
open(vw);
% ---- Figure & axes (keep simple for Online) ----
figW = 640; figH = 360; % modest, consistent size
animFig = figure('Color','w','Units','pixels', ...
'Position',[100 100 figW figH], 'Resize','off');
ax = axes('Parent',animFig); hold(ax,'on'); axis(ax,'equal'); axis(ax,'off');
plot(ax, [0 1], [0 0], 'k-', 'LineWidth',2); % the line
xlim(ax,[0 1]); ylim(ax,[-0.2 0.2]);
% ---- Ball (drawn as a filled circle) ----
r = 0.05; y0 = 0;
hBall = rectangle(ax, 'Position',[0.05-r y0-r 2*r 2*r], ...
'Curvature',[1 1], 'FaceColor',[0.20 0.35 0.85], 'EdgeColor','none');
% ---- Simple motion & capture loop ----
duration_sec = 2; % 2-second clip
nframes = duration_sec * vw.FrameRate;
xs = linspace(0.05, 0.95, nframes); % left -> right
for k = 1:nframes
set(hBall, 'Position', [xs(k)-r, y0-r, 2*r, 2*r]);
drawnow('expose'); % ensure the frame is rendered
fr = getframe(animFig); % capture the figure
writeVideo(vw, fr);
end
close(vw);
disp("Wrote video: " + string(vidfile));
Wrote video: testvideos/ball_line_20251014_201746.avi
toc
Elapsed time is 4.104192 seconds.

Réponse acceptée

Cris LaPierre
Cris LaPierre le 14 Oct 2025 à 20:04
The code completes successfully for me when I run it. It took 13-15 seconds.
Given that it does run, I'd suggest the typical actions for browser-based tools.
  1. Check that you meet the browser requirements.
  2. Try a different browser
  3. Try clearing your cookies and cache
  4. Try signing out and signing back in. I'd suggest waiting ~15 mins to ensure you get a fresh worker.
If it still doesn't work, follow these instructions to reset your session.
If that doesn't work, contact technical support.
  4 commentaires
Duncan Carlsmith
Duncan Carlsmith le 15 Oct 2025 à 2:33
Har har!
Cris LaPierre
Cris LaPierre le 15 Oct 2025 à 12:15
For performance issues, please report those directly to MathWorks: https://www.mathworks.com/support/contact_us.html

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Produits


Version

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by