# Solving mach Zehnder interferometer using matrix

68 views (last 30 days)
Sagarika Gupta on 18 May 2020
Answered: MOHD IMRAN KHAN on 18 Jan 2022
Hii everyone, I am sagarika gupta and this programming software is new for me and so please help me to slove mach zehnder using matrix method (as given below the matrices equaions(3),(4)&(5)). As we know that mach zehnder interferometer consists of two directional coupler and two arms we give one input and get two output(either we will get at arm 1 or at arm 2) and there is two phase shifters in the arms which will regularly change their phase . I want to plot this matrix for the machzehnder interferometer ,and i am unable to do it. So, with due respect i request to all the community memebers to help me.

Ryan Comeau on 19 May 2020
Edited: Ryan Comeau on 19 May 2020
Hello,
great question, haven't tackled a physics one for a while. First off, cool that you're working on interferometers, they are fun to work with.
Secondly, if MATLAB is new to you, know that all variables are stored as matrices, so performing the "*" operation is a matrix multiplication operation. To perform a scalar multiplication of a matrix use ".*". Also, MATLAB does store the real and imaginary parts, and we can extract them seperately.
So, let's rock and roll to some code here, I would like to note that this will only help you get started, you may need to modify this for your particular operation. I'm going to write this code for you to compute the matrix in equation 4. This way, you can change the r and t values along with the phase difference.
%first, we want to initialise some variables
optical_field_transmission=0.5; %i don't know the domain for this (0-1?)
cross_coupling_coefficient=0.5; %i don't know the domain for this (0-1?)
phase_angle_one=pi/4; %check rads vs degrees in MATLAB, ther are unique functions for each.
phase_angle_two=pi/4;
transfer_matrix(1:2,1:2)=zeros(); %initialise the transfer matrix.
%compute the transfer matrix component by component
% "i" here is sqrt(-1)
transfer_matrix(1,1)=((optical_field_transmission.^2)*exp(i*phase_angle_one))...
-((cross_coupling_coefficient.^2)*exp(i*phase_angle_two));
transfer_matrix(2,2)=((optical_field_transmission.^2)*exp(i*phase_angle_two))...
-((cross_coupling_coefficient.^2)*exp(i*phase_angle_one));
transfer_matrix(1,2)=i.*optical_field_transmission.*cross_coupling_coefficient.*...
(exp(i*phase_angle_one)+exp(i*phase_angle_two));
transfer_matrix(2,1)=i.*optical_field_transmission.*cross_coupling_coefficient.*...
(exp(i*phase_angle_one)+exp(i*phase_angle_two));
So, if you want the matrix values for a single set of input parameters, used the above code. Below i'll write the code to plot the whole domain for each of your parameters(you'll need to change the t and r as i don't know their domains). I will also give you some tools to plot them. We are storing the data in a 4 dimension space, and you'll need to bring that down to 2d in order to plot in MATLAB. this means you'll need to choose fixed values for 3 parameters. Please validate the equations below. If i've made an error it is important that you notice it.
%we are going to us 4 nested for loops to iterate over all possible combinations.
%we are going to take 0.1 increments of r and t
%we are going to take 1.0 increments of phase angles.
n=1;
m=1;
f=1;
d=1;
for ii=1:0.05:pi %phase angle 1 indexed with d
for jj=1:0.05:pi %phase angle 2 indexed with f
for kk=0.1:0.1:1 %for t, indexed with n
for ll=0.1:0.1:1 %for r, indexed with m
data_vault_entry_one_one(d,f,n,m)=((kk.^2)*exp(i*ii))-((ll.^2)*exp(i*jj));
data_vault_entry_two_two(d,f,n,m)=((kk.^2)*exp(i*jj))-((ll.^2)*exp(i*ii));
data_vault_entry_one_two(d,f,n,m)=i.*kk.*ll.*(exp(i*ii)+exp(i*jj));
data_vault_entry_two_one(d,f,n,m)=i.*kk.*ll.*(exp(i*ii)+exp(i*jj));
m=m+1;
end
n=n+1;
end
f=f+1;
end
d=d+1;
end
So this will fill up the data vaults for you. Each data vault has the entry for one of the matrix parameters, you now need to choose which matrix entry you want to plot and which parameters you want fixed. Please read through the plot function, it is very elaborate. Here is one example:
%plot all entries of phase angle one for given other parameters
plot(data_vault_entry_one_one(:,pi/4,2,3))
%plot all entries of phase angle two for given other parameters
plot(data_vault_entry_two_one(pi/2,:,5,6))
Hope this helps get you started, please validate what i've written here
RC
Sagarika Gupta on 20 May 2020
Thanks Ryan for helping me and i will follow the advice for writing the matrix code you have told me. Really, thanks once again.

MOHD IMRAN KHAN on 18 Jan 2022
Hello Sagarika. Did you implement MZ interferometer in MATLAB successfully? If yes then please send me code. It will be a great support form your side. Thank You.
Email id: imrank9319@gmail.com

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by