Error using ode arguments (line 90) SCHROE must return a column vector?
1 次查看(过去 30 天)
显示 更早的评论
This is to simulate a nth Eigenstate of a initial hamiltonian being carried under the Schrodinger equation to the nth eigenstate of the final hamiltonian.
Script:
function [dy]= schroe(t, y);
global lambda Delta
H0 = [ lambda*t, Delta
Delta, -lambda*t];
dy=-1i*H0*y;
Command Window:
lambda=1;
Delta=1;
Hz=20;
tt = [0/lambda:Hz/lambda/200:Hz/lambda];
y0 = [.999688036058711-.024976600270607];
options = odeset('Reltol', 1e-6, 'AbsTol', 1e-6);
[ttotal, ytotal] = ode45(@schroe, tt, y0, options);
for ii= 1:201;
ti=tt(ii);
H0 = [ lambda*ti, Delta
Delta, -lambda*ti];
[vt, et] = eig(H0);
psit=transpose(ytotal(ii,:));
vg=vt(:,1);
ve=vt(:,2);
cg(ii)=vg'*psit;
ce(ii)=ve'*psit;
end;
Error:
Error using odearguments (line 90)
SCHROE must return a column vector.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in lz_2level_simu_lt (line 27)
[ttotal, ytotal] = ode45(@schroe, tt, y0, options);
Please Help
0 个评论
采纳的回答
Walter Roberson
2016-11-17
Your y0 is
y0 = [.999688036058711-.024976600270607];
which is a numeric scalar. Your schroe function is therefore going to receive numeric scalars for y, and will construct -1i*H0*y where H0 is a 2 x 2 matrix. That is going to give a 2 x 2 result, and that is going to fail the consistency tests. It also fails the consistency tests about the number of returned elements being the same as the number of inputs, since you are returning 4 outputs for 1 input.
If your y0 were instead
y0 = [.999688036058711 -.024976600270607];
which would be a vector of length 2, then the ode45 would create a column vector from the size, and so would be passing in 2 x 1 for y. Your -1i*H0*y would then be doing matrix multiplication, (2 x 2) * (2 * 1) which would give a 2 x 1 result, which would be fine.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!