# Simulation with Matlab: wave scattering and Radar back signals

## Illustration of shape effects on radar cross section (RCS)

First the animation: that is video from figure 5., introducing wave scattering and some stealthness principles, here effects of the shape of the object on radar signals reduction.

Compare with to figure 3.: same object but with a sligthly different orientation…

Simulation and computationnal aspects rely on finite difference method, see for example (french) this page and also for example (also french) introduction to Matlab programming, and more specifically activities 8, simulation of monodimensionnal wave scattering, 9, simulation of bidimensionnal wave scattering, and 10, simulation of wave scattering inside a medium.

About the simulation and animation on which result is shown on top, the Matlab code is:

```
clear all;close all
clc;
c=8; % wave speed
Lx=100;Ly=Lx;
Nx=150;Ny=150;
dx=Lx/Nx;dy=Ly/Ny;
x=linspace(0,Lx,Nx);
y=linspace(0,Ly,Ny);
dt=sqrt(dx^2+dy^2)/(2*c);
nu=1; % source frequency
Temis=4; % source emitting duration
T=20;
t=[0:dt:T];Nt=length(t);
gax=c^2*dt^2/dx^2;
gay=c^2*dt^2/dy^2;
% Source location
sx=round(Nx/8);
sy=round(Ny/8);
u=zeros(Nx,Ny,Nt);
% Obstacle 1
Ox=round(Nx/2);Oy=round(Ny/2);%centre
for k=2:Nt-1
for i=2:Nx-1
for j=2:Ny-1
tmp1=u(i-1,j,k)+u(i+1,j,k)-2*u(i,j,k);
tmp2=u(i,j-1,k)+u(i,j+1,k)-2*u(i,j,k);
u(i,j,k+1)=2*u(i,j,k)-u(i,j,k-1)+gax*tmp1+gay*tmp2;
end
end
if (k*dt<Temis)
u(sx,sy,k+1)=2*sin(2*pi*nu*k*dt);
else
u(sx,sy,k+1)=0;
end
for l=0:15
X=Ox+l;
for XX=-l:l
Z=X+XX;
u(Z,-Z+2*X,k+1)=0;
end
end
%
% Not wanted reflections (absorbing conditions):
u(1,:,k+1)=u(2,:,k);
u(Nx,:,k+1)=u(Nx-1,:,k);
u(:,1,k+1)=u(:,2,k);
u(:,Ny,k+1)=u(:,Ny-1,k);
end
% For source drawing purpose
u(sx,sy,:)=10;
for l=0:15
X=Ox+l;
for XX=-l:l
Z=X+XX;
u(Z,-Z+2*X,:)=10;
end
end
fig=figure(1);clf;whitebg('w')
colormap(jet)
MM=[];
for k=1:2:Nt
subplot(211);
%imagesc(squeeze(u(:,:,k)));
pcolor(squeeze(u(:,:,k)));
axis off,axis square
shading interp
caxis([-0.5 2])
%colorbar
subplot(212),hold on
pp=plot([1:k]*dt,squeeze(u(sx+3,sy+3,1:k)));
set(pp,'linewidth',3')
pp=plot(t,zeros(size(t)),'--k');
set(pp,'linewidth',0.5')
axis([0 T -0.6 0.6])
xlabel('Temps [ms]','fontsize',16)
ylabel('Amplitude','fontsize',16)
grid on
%pause(0.01)
MM=[MM getframe(fig)];
end
%break
movie2avi(MM,'Film.avi')
```

Video resulting from

`movie2avi`

is usually a heavy (if not
really huge) one.
One can directly enable Matlab to use some codecs, see

`movie2avi`

parameters, via
`help movie2avi`

or, also see Matlab alternative solution to video generation:
`VideoWriter`

,
which is to used nearly the same way as `movie2avi`

,
but is a rather more complete with respect to codecs;
see the list of available "profiles"
`VideoWriter.getProfiles()`

Another alternative is to convert video after Matlab process, via for example

`ffmpeg`

`ffmpeg -i film.avi film.mp4`

which one can then use directly use, for example, inside html5 <video> (as at the top of page), or to convert to animated gif, via

`convert`

utility
(`ImageMagic`

software)
`convert -loop 2 film.avi film.gif`