@Tejas Shetty: it is time for you to do some debugging. Start by looking at the size of H, and thinking about why you expect index m to be <= the number of elements of H.
error index exceeds matrix dimensions
1 次查看(过去 30 天)
显示 更早的评论
getting error index exceeds matrix dimensions at line h = H{m}; %index exceeds matrix dimensions inside the for loop
1.% function [rho] = blah(start,rho0)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
load definitions.mat
load parameters.mat
[a,adag,II,A,Ad] = Nho_stuff(Nho,gam);
whos a adag II A Ad
whos start
H = Hamiltonian(start);
whos H
nt = Nt+1;
rho=cell(nt,1);
rho{1}=rho0;
m=1;
dt=tunit;
% tind=1:1:Nt;
% time=tind*tunit;
% whos H{1}
%h=zeros(length(rho0));
for i = 1: nt
if(abs(mod(i,C))<eps) %mod(i,C)=0
m=m+1;
end
h = H{m}; %index exceeds matrix dimensions
% h=H(m); %defines it as a cell rather than a matrix
% h=cell2mat(H(m)); %index exceeds matrix dimensions
ro=rho{i};
ihdt = -1i*h*dt;
ih2dt2 = 0.5*ihdt*ihdt;
droh = ihdt*ro - ro*ihdt- 2*(ihdt*ro*ihdt) + ro*ih2dt2 + ih2dt2*ro; % 0;%
dro = droh + (A*ro*Ad-(1/2)*Ad*A*ro-(1/2)*ro*Ad*A)*dt;
rho{i+1}=rho{i}+dro;
rho{i+1}=rho{i+1}/real(trace(rho{i+1}));
end
end
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!