MATLAB online video creation trouble

조회 수: 32 (최근 30일)
Duncan Carlsmith
Duncan Carlsmith 2025년 10월 14일 17:54
댓글: Cris LaPierre 2025년 10월 15일 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.

채택된 답변

Cris LaPierre
Cris LaPierre 2025년 10월 14일 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
Duncan Carlsmith
Duncan Carlsmith 2025년 10월 15일 2:33
Har har!
Cris LaPierre
Cris LaPierre 2025년 10월 15일 12:15
For performance issues, please report those directly to MathWorks: https://www.mathworks.com/support/contact_us.html

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by