gr=0.25+0.01*(1+sin(k*x));
gl=0.75+0.01*(1+sin(k*x));
K=1/(0.05*sqrt(2*pi))*exp(-0.5*(s/0.05)^2);
y= b*K*v(x+s)+d*K*ur(x+s);
Array indices must be positive integers or logical values.
ur(j,n)=fr(j)-0.5*mu1*(fr(j)-fr(j-1))+dt*lambdau2*(0.5+0.5*tanh(1-z))*fl(j)-dt*lambdau1*(0.5+0.5*tanh(1-z))*fr(j)-dt*beta*fr(j)*(gr(j)+gl(j))+dt*0.5*alpha*(gr(j)+gl(j));
ul(j,n)=fl(j)+0.5*mu1*(fl(j+1)-fl(j))+dt*lambdau1*(0.5+0.5*tanh(1-z))*fr(j)-dt*lambdau2*(0.5+0.5*tanh(1-z))*fl(j)-dt*beta*fl(j)*(gr(j)+gl(j))+dt*0.5*alpha*(gr(j)+gl(j));
vr(j,n)=gr(j)-0.5*mu2*(gr(j)-gr(j-1))+dt*lambdav2*(0.5+0.5*tanh(1-bV*(gr(j)+gl(j))+dV*fr(j)))*gl(j)-dt*lambdav1*(0.5+0.5*tanh(1-bV*(gr(j)+gl(j))+dV*fl(j)))*gr(j)+dt*beta*fr(j)*(gr(j)+gl(j))-dt*alpha*gr(j);
vl(j,n)=gl(j)+0.5*mu2*(gl(j+1)-gl(j))+dt*lambdav1*(0.5+0.5*tanh(1-bV*(gr(j)+gl(j))+dV*fl(j)))*gr(j)-dt*lambdav2*(0.5*+0.5*tanh(1-bV*(gr(j)+gl(j))+dV*fr(j)))*gl(j)+dt*beta*fl(j)*(gr(j)+gl(j))-dt*alpha*gl(j);
ur(J+1,1)= fr(J+1)-0.5*mu1*(fr(J+1)-fr(J))+dt*lambdau2*(0.5+0.5*tanh(1-b*(gr(J+1)+gl(J+1))+d*fr(J+1)))*fl(J+1)-dt*lambdau1*(0.5+0.5*tanh(1-b*(gr(J+1)+gl(J+1))+d*fl(J+1)))*fr(J+1)-dt*beta*fr(J+1)*(gr(J+1)+gl(J+1))+dt*0.5*alpha*(gr(J+1)+gl(J+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0.5+0.5*tanh(1-bV*(vr(1,n-1)+vl(1,n-1))+dV*ul(1,n-1)))*vr(1,n-1)-dt*lambdav2*(0.5*+0.5*tanh(1-bV*(vr(1,n-1)+vl(1,n-1))+dV*ur(1,n-1)))*vl(1,n-1)+dt*beta*ul(1,n-1)*(vr(1,n-1)+vl(1,n-1))-dt*alpha*vl(1,n-1);
vl(J+1,n)=vl(J+1,n-1)+0.5*mu2*(vl(1,n-1)-vl(J+1,n-1))+dt*lambdav1*(0.5+0.5*tanh(1-bV*(vr(J+1,n-1)+vl(J+1,n-1))+dV*ul(J+1,n-1)))*vr(J+1,n-1)-dt*lambdav2*(0.5*+0.5*tanh(1-bV*(vr(J+1,n-1)+vl(J+1,n-1))+dV*ur(J+1,n-1)))*vl(J+1,n-1)+dt*beta*ul(J+1,n-1)*(vr(J+1,n-1)+vl(J+1,n-1))-dt*alpha*vl(J+1,n-1);
u_ex(j,n)=exp(-c*(xj-au*t-0.5)^2);
set(ss,'edgecolor','none');
xlabel('t','FontSize',28);
ylabel('x','FontSize',28);
title('u^++u^-','FontSize',28);
set(ss,'edgecolor','none');
xlabel('t','FontSize',28);
ylabel('x','FontSize',28);
title('v^++v^-','FontSize',28);
set(ss,'edgecolor','none');
xlabel('t','FontSize',28);
ylabel('x','FontSize',28);
title('u^+','FontSize',28);
set(ss,'edgecolor','none');
xlabel('t','FontSize',28);
ylabel('x','FontSize',28);
title('v^+','FontSize',28);
set(ss,'edgecolor','none');
xlabel('t','FontSize',28);
ylabel('x','FontSize',28);
title('u^-','FontSize',28);
set(ss,'edgecolor','none');
xlabel('t','FontSize',28);
ylabel('x','FontSize',28);
title('v^-','FontSize',28);
set(ss,'edgecolor','none');
xlabel('t','FontSize',28);
ylabel('x','FontSize',28);
title('v^++v^-','FontSize',28);
set(ss,'edgecolor','none');
xlabel('t','FontSize',28);
ylabel('x','FontSize',28);
title('u^++u^-','FontSize',28);