问题遇到的现象和发生背景
运行图像没有问题、但在运行后matlab2020a报错
想请问一下怎么解决这个报错。
问题相关代码,请勿粘贴截图
clear;
dx=0.01; Imax=100; nmax=500;
c=3e8; omega=2*pi*300e6; dt=dx/c;
x=linspace(dx,Imax*dx,Imax); % 二维情况,请使用meshgrid生成网格。[x,y]=meshgrid(....)
ii=1:Imax;
f1(1:Imax)=sin(ii*dx); %二维情况,f1是个二维函数。
plot(x,f1)
ylabel('f1');
M=moviein(nmax/2,gcf);
%***********************************************************************
% BEGIN TIME-STEPPING LOOP
%***********************************************************************
for n=1:nmax
%***********************************************************************
% Update sin(wt-x)
%***********************************************************************
f1(1:Imax)=sin(omega*n*dt-ii*dx);
%***********************************************************************
% Visualize fields
%***********************************************************************
if mod(n,2)==0
rtime=num2str(round(n*dt/1.0e-9));
plot(f1) %二维情况,请使用mesh画图,mesh(f1)
title(['time = ',rtime,' ns']);
ylabel('f1');
M(:,n/2)=getframe(gcf);
end
%***********************************************************************
% END TIME-STEPPING LOOP
%***********************************************************************
end
movie(M)[]([]())
运行结果及报错内容
运行图像没有问题但命令行窗口报错
具体如下:
此类型的变量不支持使用点进行索引。
出错 alternateGetframe
出错 getframe (line 148)
x = alternateGetframe(parentFig, offsetRect, scaledOffsetRect, includeDecorations);
出错 try2 (line 26)
M(:,n/2)=getframe(gcf);