# Sine Dipole formation using two hydrophones

I am trying to do MATLAB simulations for generation of SINE Dipole using two hydrophones spaced distance 'd' apart for signal coming from direction 'DOA'. The MATLAB code is given below. The confusion is that there is constant phase difference of 90 degree b/w SINE Dipole generated using difference of two hydrophones and simple SINE Dipole generated by multiplication of signal with sin(DOA). There is also a difference b/w amplitude of two Dipoles. The resultant graph of MATLAB code is also attached. Am i doing right or something is not right in my understanding?

clc
clear
close all

f_sig = 800;%signal frequency in Hz
f_samp = 64000; %Sampling rate
N=81920;%no of data points
c=1500;%sound speed in water in m/s
d=50e-3;%spacing b/w two omni directional hydrophones

DOA=135;%Direction of signal in deg

t=(0:N-1)/f_samp;

lemda=c/f_sig;

Hyd_1=sin(2*pi*f_sig*t+2*pi*(d/2)*sind(DOA)/lemda);
Hyd_2=sin(2*pi*f_sig*t-2*pi*(d/2)*sind(DOA)/lemda);

%Formation of Sinusoidal dipole using two hydrophones Hyd_1 & Hyd_2
Sine_Dipole_1=(Hyd_1-Hyd_2);

%Formation of Sinusoidal by multiplying with sin(DOA)
Sine_Dipole_2=sin(2*pi*f_sig*t)*sind(DOA);

plot(Sine_Dipole_1(1:1000))
hold on
plot(Sine_Dipole_2(1:1000),'r') • The best way to test code is to build test cases with known inputs and known outputs and make sure that your code passes them. Why do you think your code is wrong ? – Hilmar Jul 11 '20 at 12:09
• In my understanding, if my method of simulating SINE Dipole using difference of two hydrophones outputs i.e. Sine_Dipole_1 is correct, its output should exactly match Sine_Dipole_2 output. – naumankalia Jul 12 '20 at 11:52

As you've defined Hyd_1 and Hyd_2, you are simulating a two element hydrophone array with the array center defined at the middle of the two elements. In that case, Sine_Dipole_1 should be defined as the sum of the two elements, not the difference.

I hope this helps.

• By summing two hydrophones, i do not get dipole plot (like figure of 8) when angle varies from 0 to 360 degree. Instead, i get omni directional response. – naumankalia Jul 13 '20 at 17:33
• Your code above does not vary the direction of arrival - you are varying the time. The sine wave depicted in your image is the variation of amplitude with time, not angle of arrival. What you are trying to achieve is calculating the array factor Typically, the response of each element is summed with all the others in order to increase/shape the gain response of the array. – user51411 Jul 15 '20 at 1:31

If I plot signal magnitude of both Sine_Dipole_1 and Sine_Dipole_2 against angles from 0 to 360, i get following results: The MATLAB Code:

clc
clear
close all

f_sig = 800;%signal frequency in Hz
f_samp = 64000; %Sampling rate
N=81920;%no of data points
c=1500;%sound speed in water in m/s
d=50e-3;%spacing b/w two omni directional hydrophones

DOA=135;%Direction of signal in deg

t=(0:N-1)/f_samp;

lemda=c/f_sig;

indx_=0;

fft_points=N;
NFFT = fft_points;%2^nextpow2(L); % Next power of 2 from length of y
f = f_samp/2*linspace(0,1,NFFT/2+1);

for DOA=0:359

indx_=indx_+1;
Hyd_1=sin(2*pi*f_sig*t+2*pi*(d/2)*sind(DOA)/lemda);
Hyd_2=sin(2*pi*f_sig*t-2*pi*(d/2)*sind(DOA)/lemda);

%Formation of Sinusoidal dipole using two hydrophones Hyd_1 & Hyd_2
Sine_Dipole_1=(Hyd_1-Hyd_2);

%Formation of Sinusoidal by multiplying with sin(DOA)
Sine_Dipole_2=sin(2*pi*f_sig*t)*sind(DOA);

FFT_Dipole1 = fft(Sine_Dipole_1,NFFT)/N;
FFT_Dipole2 = fft(Sine_Dipole_2,NFFT)/N;

angle_(indx_)=DOA*pi/180;
Dipole1_Amp(indx_)=2*abs(FFT_Dipole1(1025));
Dipole2_Amp(indx_)=2*abs(FFT_Dipole2(1025));

end

ax = polaraxes;
polarplot(ax,angle_,Dipole1_Amp)
hold on
polarplot(ax,angle_,Dipole2_Amp,'r')