Index a matrix multiplied by a time dependent function

3 visualizaciones (últimos 30 días)
guilherme stahlberg
guilherme stahlberg el 10 de Jul. de 2019
Comentada: Walter Roberson el 12 de Jul. de 2019
Hi there,
I'm trying to index a matrix that's multiplied by a time dependent function, but keep getting the error "inner dimensions must agree" in the U expression line. I need to know the exact matrix values for each interaction related to the function E(t) in the time, i.e., U(1) related to E(1) and so on. Thanks in advance!
Here's the code
%% Quantum Control
format long
clear all
clc
%% Variables
fs=10;
ft = -20000:1/fs:20000; % Time
alpha = 0.001; % Time parameter
beta = 0.001; % Time parameter
ai = 0.2; % Pop |1>
ai2 = 0.8; % Pop |2>
af = 1; % Pop Final |1>
w0 = 0.02; % w0 = (E2 - E1)/h
mi = 6; % Dipole
phii = pi/24; % Relative phase
phif = pi/4; % Relative phase final
E1 = 1; % Energy
E2 = 2; % Energy 2
H = [0 1;1 0]; % Interaction hamiltonian
H0 = [E1 0;0 E2]; % Matriz do Hamiltoniano sem Interação
%% 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
  2 comentarios
Walter Roberson
Walter Roberson el 10 de Jul. de 2019
V.*Z1.*inv(V) is probably a mistake. Any multiplication of a matrix and its inverse should be using * instead of .*
You should likely also be coding using Z1/V instead of Z1.*inv(V)
In your long expression you have a / that should probably be ./
guilherme stahlberg
guilherme stahlberg el 10 de Jul. de 2019
I've tried either * or .* but keep getting the same error "inner dimensions must agree". Same regarding the / and./

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 10 de Jul. de 2019
U = zeros(2,2,length(ft)) ;
for i = 1:length(ft)
U(:,:,i) = exp(-1i.*ft(i)./2).*Z.*exp(1i.*mi.*E(i).*ft(i)).*V.*Z1.*inv(V).*exp(-1i.*ft(i)./2).*Z;
end
  1 comentario
Walter Roberson
Walter Roberson el 12 de Jul. de 2019
This is likely to be mathematical nonsense though. V.*Z1.*inv(V) is much more likely to need V*Z1*inv(V) or similar.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Quantum Mechanics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by