[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Can't get a differential function to work

**From**: |
tessaract87 |

**Subject**: |
Can't get a differential function to work |

**Date**: |
Thu, 23 Oct 2014 12:17:31 -0700 (PDT) |

I've created a function with the form
function ydot = f(t,y)
a=0.004;
b=0.00002;
ydot=[-y(1).*y(2)*b; y(1).*y(2)*b-y(2)*a];
endfunction
Running it results in the following:
error: 'y' undefined near line 4 column 8
error: called from:
error: /home/tessa/Documents/Octave Models/dy.m at line 4, column 5
Trying to actually analyze with lsode results in this:
y=lsode(@f,[10,990],t);
a = 0.0040000
b = 2.0000e-04
error: f: A(I): index out of bounds; value 2 out of bound 1
error: called from:
error: f at line 4, column 3
error: lsode: evaluation of user-supplied function failed
error: lsode: inconsistent sizes for state and derivative vectors
Now, for context, this problem is from a textbook written for MATLAB, so I
have no clue if the formatting is correct (it probably isn't).
Clearly, I need to define y (somehow)- but I have no idea how.
Help?
--
View this message in context:
http://octave.1599824.n4.nabble.com/Can-t-get-a-differential-function-to-work-tp4667087.html
Sent from the Octave - General mailing list archive at Nabble.com.

**Can't get a differential function to work**,
*tessaract87* **<=**