You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: initial_field_coefficients_planewave.m
    path of file: ./repos/celes/src/initial
    
    the code of the file until where you have to start completion: %  Copyright (c) 2017, Amos Egel (KIT), Lorenzo Pattelli (LENS)
%                      Giacomo Mazzamuto (LENS)
%  All rights reserved.
%
%  Redistribution and use in source and binary forms, with or without
%  modification, are permitted provided that the following conditions are met:
%
%  * Redistributions of source code must retain the above copyright notice, th
    
function aI = initial_field_coefficients_planewave(simulation)

lmax = simulation.numerics.lmax;
E0 = simulation.input.initialField.amplitude;
k = simulation.input.k_medium;

beta = simulation.input.initialField.polarAngle;
cb = cos(beta);
sb = sin(beta);
alpha = simulation.input.initialField.azimuthalAngle;

% pi and tau symbols for transformation matrix B_dagger
[pilm,taulm] = spherical_functions_trigon(cb,sb,lmax);  % Nk x 1

% cylindrical coordinates for relative particle positions
relativeParticlePositions = simulation.input.particles.positionArray - simulation.input.initialField.focalPoint;
kvec = k*[sb*cos(alpha);sb*sin(alpha);cb];
eikr = exp(1i*relativeParticlePositions*kvec);

clear k beta cb sb kvec relativeParticlePositions % clean up some memory?

% compute initial field coefficients
aI = simulation.numerics.deviceArray(zeros(simulation.input.particles.number,simulation.numerics.nmax,'single'));
for m=-lmax:lmax
    for tau=1:2
        for l=max(1,abs(m)):lmax
            n=multi2single_index(1,tau,l,m,lmax);
            aI(:,n) = 4 * E0 * exp(-1i*m*alpha) .* eikr .* transformation_coefficients(pilm,taulm,tau,l,m,simulation.input.initialField.pol,'dagger');
        end