How to index matrices inside a loop?
Show older comments
Hey all,
I'm trying to index a matrix on witch it's elements vary inside a loop. The code aims to evaluate the time evolution operator in a 2-level quantum system, therefore I need to be able to identify the matrix in a specific time interation, i.e., I need to know the matrix values at U(1), U(20000) and so on. I apologize if it's a simple matter, I'm a self-taught MATLAB user and haven't found any awnsers using the search engine. Thanks in advance!
Here is the code
%% Quantum Control
format long
clear all
clc
%% Variables
for ft = -20000:.1:20000 % Time
alpha = 0.001; % Transition parameter
beta = 0.001; % Transition parameter
ai = 0.2; % Initial population |1>
ai2 = 0.8; % Initial population |2>
af = 1; % Final population |1>
w0 = 0.02; % w0 = (E2 - E1)/h
mi = 6; % dipole operator
phii = pi/24; % initial relative phase
phif = pi/4; % final relative phase
E1 = 1.98; % eigen-energy 1
E2 = 2; % eigen-energy 2
H = [0 1;1 0]; % Interation hamiltonian
H0 = [E1 0;0 E2]; % hamiltonian
%% Control function
g = 1./(1+exp(-alpha.*ft));
f = ai*(1-g)+af*g;
p = 1./(1+exp(-beta.*ft));
h = phii*(1-p)+phif*p;
%% Electric field
E = alpha.*(af-ai).*exp(alpha.*ft).*sin(w0.*ft+h)./(mi.*(1+exp(alpha.*ft)).*sqrt((1-ai+(1-af).*exp(alpha.*ft)).*(ai+af.*exp(alpha.*ft))))+2.*beta.*(phif-phii).*exp(beta.*ft).*sqrt(f.*(1-f)).*cos(w0.*ft+h)/(mi.*(1-2.*f).*(1+exp(beta.*ft).^2));
%% Time evolution operator
[V, D]=eig(H);
Z = expm(H0);
Z1 = expm(D);
U = exp(-1i*ft/2)*Z*exp(1i*mi*E*ft)*V*Z1*inv(V)*exp(-1i*ft/2)*Z
end
%% End
Accepted Answer
More Answers (0)
Categories
Find more on Quantum Mechanics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!