help-octave
[Top][All Lists]

## Re: ode45 issue: dimension mismatch

 From: Sebastian Schöps Subject: Re: ode45 issue: dimension mismatch Date: Wed, 7 Feb 2018 01:31:08 -0700 (MST)

```Tweetman wrote
> Hello, sorry for the confusion. Yes, what I meant was
> dx/dt = M*(x^m)*(1-x)^n

If the initial value is x(0)=0 then your ODE will only have the trivial
solution x=0.

Tweetman wrote
> clear; clc;
> t = linspace(0,400,101);
> x0 = [0, 0];
> function f = dx(x,t)
> M = 2.933e-5;
> m = 0.158;
> n = 1.26;
> dx = M*(x.^m)*(1-x).^n;
> endfunction
> [t,x] = ode45(@dx, t, x0);

* I suggest to use a anonymous function, see
https://www.gnu.org/software/octave/doc/v4.2.0/Anonymous-Functions.html
* Your initial value as two components but it is a scalar ode

Try this:

t = linspace(0,400,101);
x0 = 0;
M = 2.933e-5;
m = 0.158;
n = 1.26;
dx = @(t,x) ( M*(x.^m)*(1-x).^n );
[t,x] = ode45(dx, t, x0);
plot(t,x)

and enjoy the zero function :)

Seb.

--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

```