L_x=10.0;
w_0=1.0;
lambda=0.6;
n=1.0;
k_0=2*pi/lambda;
N_x=128;
Delta_x=L_x/(N_x-1);
h=5*Delta_x;
N_z=100;
plotting=zeros(N_x,N_z);
x=linspace(-0.5*L_x,0.5*L_x,N_x);
x=x';
E=exp(-(x/w_0).^2);
z=0;
z_plot=zeros(N_z);
for r=1:N_z
z=z+h;
z_plot(r)=z+h;
plotting(:,r)=abs(E).^2;
E=step(Delta_x,k_0,h,n,E);
end
for k=1:N_z/10:N_z
plot(plotting(:,k),'LineWidth',1.5)
set(gca,'FontSize',14);
hold on
end
pause
close all
for k=1:N_z/10:N_z
y=z_plot(k)*ones(size(x));
plot3(x,y,plotting(:,k),'LineWidth',1.5)
hold on
end
grid on
xlabel('x','FontSize',14)
ylabel('z','FontSize',14)
set(gca,'FontSize',14);
pause
close all
出现的错误如下图所示,还请大佬指点迷津!非常感谢!