フィルターのクリア

error index exceeds matrix dimensions

1 回表示 (過去 30 日間)
Tejas Shetty
Tejas Shetty 2017 年 12 月 9 日
コメント済み: Stephen23 2017 年 12 月 9 日
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
Remaining files could be found here total code
  1 件のコメント
Stephen23
Stephen23 2017 年 12 月 9 日
@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.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by