help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ode45 error: dimension mismatch in line 345 column 17


From: Dalton Jones
Subject: ode45 error: dimension mismatch in line 345 column 17
Date: Sun, 27 Aug 2017 13:05:56 -0700

I am trying to solve this complex ODE with ode45 and no matter which solver I use I get a similar error from each solver (using odepkg 0.8.5). I've used octave online to solve the very same ode as well as matlab, but I need to be able to solve it using my octave version 4.0.3.

function dydt=bangodefun(y,t,T,N)
  X=[Delta1(t,T(1:N(1))); Delta2(t,T(N(1)+1:sum(N(1:2)))); Delta3(t,T(sum(N(1:2))+1:sum(N(1:3)))); Delta4(t,T(sum(N(1:3))+1:sum(N(1:4)))); Delta5(t,T(sum(N(1:4))+1:sum(N(1:5)))); Delta6(t,T(sum(N(1:5))+1:sum(N(1:6))))];
  H=Hamil(X);
  dydt=-i*H*y;
endfunction

%The Delta functions simply return values 0 or 1 depending on t, T and N are defined inputs
%Hamil(X) returns a 3x3 Hamiltonian matrix which means y is a 3x1 vector

Command:
>> T=[0; 0; 0; 0; .28; .56; .28; .56];
>> N=[1 1 1 1 2 2];
>> Y0=[1; 0; 0];
>> [t,Y]=ode45(@(t,y)bangodefun(t,y,T,N), [0 1], Y0)
warning: Option "RelTol" not set, new value 0.000001 is used
warning: called from
    ode45 at line 113 column 5
warning: Option "AbsTol" not set, new value 0.000001 is used
warning: Option "InitialStep" not set, new value 0.010000 is used
warning: Option "MaxStep" not set, new value 0.010000 is used
error: ode45: A(I,J,...) = X: dimensions mismatch
error: called from
    ode45 at line 345 column 17

I'm not sure why I'm only getting this error on my downloaded version of Octave. Please help.

Thank you,
Dalton

reply via email to

[Prev in Thread] Current Thread [Next in Thread]