So apparently my textbook is out of date

I've been working out of DeVries' text on mathematical modeling for biological systems, and am working on the chapter that actually teaches you how to do all of this in Matlab. One of the examples I'm working through concerns the SIR model, and asks you to use the dsolve function to solve an ODE symbolically and for non-explicit solution, as such:
I = dsolve('DI = -1 + a/(b*S)','S')
According to the textbook, I should get a nice solved equation out of this (though it doesn't say what it should look like). However, when I actually type it into the terminal, I get
Warning, it is required that the numerator of the given ODE depends on the highest derivative. Returning NULL.
Warning, it is required that the numerator of the given ODE depends on the highest derivative. Returning NULL.
Warning, cannot find an explicit solution
{Error using maplemex Error, (in MTM:-dsolve) invalid input: indices received E, which is not valid for its 1st argument, t Error in dsolve (line 13) r = sym(maplemex(0,'MTM:-dsolve',varargin{:},'returnlist=true')); Error in matlab2211324625 (line 4) I = dsolve('DI = -1 + a/(b*S)','S');}
I'm assuming (as is my professor) that somewhere along the line, Matlab updated their formatting, and now the example equation is set up correctly. Can anyone give me any pointers on how it's supposed to look?
Thanks!

Answers (1)

Matt Tearle
Matt Tearle on 22 Oct 2014
Edited: Matt Tearle on 22 Oct 2014
What version of MATLAB are you running? (Enter version at the command prompt and it will tell you, if you're not sure.) The code you pasted works fine for me on 14b, so, if anything, you're perhaps using an older version than whatever is used in the textbook.
You could also try this:
syms I(S) a b
Isol = dsolve(diff(I) == -1 + a/(b*S))
(I get the same result -- C2 - S + (a*log(S))/b -- either way.)

6 Comments

The book has a publication data of 2006.
That produces this error message:
{Error using assignin Invalid variable name "I(S)" in ASSIGNIN. Error in syms (line 56) assignin('caller',varargin{i},sym(varargin{i})); Error in matlab2214658358 (line 4) syms I(S) a b}
Also, part of the problem is probably the fact that I actually don't have a version- I'm too broke to afford MATLAB, so instead I use an online service offered by my university's math department, where you type in the code into a box on their website, and it automatically runs on their machines and then displays the answers. It's possibile however they set this up doesn't play nice with the symbolic logic toolbox.
Yes, that sounds very much like the problem. It seems like there is some Symbolic Math TB support, though, because you were initially getting errors about dsolve.
So, firstly, does the version command work? If so, what does it give you? (You could also try ver to see all the products installed.)
And how about this as a third syntax option:
a = sym('a');
b = sym('b');
S = sym('S');
I(S) = sym('f(S)');
Isol = dsolve(diff(I) == -1 + a/(b*S))
Note that if you're too broke for matlab, there's GNU octave that's supposed to be an open source replacement for matlab. I've never tried it so I don't know how compatible it is.
I just noticed that you have your university in your profile, but I'm having a hard time figuring out your license options. You could try calling Customer Support and see if they can work out if you have any kind of license available (through the school) -- 508 647 7000 (8:30-5:30 Eastern)
There is also Julia, although I don’t know if it has a symbolic toolbox.

Sign in to comment.

Products

Tags

Asked:

on 22 Oct 2014

Commented:

on 23 Oct 2014

Community Treasure Hunt

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

Start Hunting!