필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by