Results 1 to 3 of 3

Math Help - Issue With MATLAB Homework Problem

  1. #1
    Newbie
    Joined
    Feb 2009
    Posts
    2

    Issue With MATLAB Homework Problem

    Hey guys,

    Long story short, my DiffEq class has to use MATLAB, but they're not really teaching it to us. I'm trying my best to do some problems given to us, but it's difficult to do this stuff if you don't have much experience.

    So here's the problem:


    Apparently we're supposed to use 'inline' and 'ode45' to solve this, and then plot it.

    So I started with this:

    >> f=inline('[-.1*x(1)*x(2);-1*x(1)]','x','t')

    f =

    Inline function:
    f(x,t) = [-.1*x(1)*x(2);-1*x(1)]

    ...and then I tried this and got a bunch of errors:

    [t y]=ode45(f,[0,15],[10,15])

    Not quite sure what the problem is here. If anyone could help me out a little bit, I'd greatly appreciate it.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by EddieB View Post
    Hey guys,

    Long story short, my DiffEq class has to use MATLAB, but they're not really teaching it to us. I'm trying my best to do some problems given to us, but it's difficult to do this stuff if you don't have much experience.

    So here's the problem:


    Apparently we're supposed to use 'inline' and 'ode45' to solve this, and then plot it.

    So I started with this:

    >> f=inline('[-.1*x(1)*x(2);-1*x(1)]','x','t')

    f =

    Inline function:
    f(x,t) = [-.1*x(1)*x(2);-1*x(1)]

    ...and then I tried this and got a bunch of errors:

    [t y]=ode45(f,[0,15],[10,15])

    Not quite sure what the problem is here. If anyone could help me out a little bit, I'd greatly appreciate it.
    These are the Lanchester equations appropriate to guerilla warfare, where the rate of casulties inflicted by the regular forces is proportional to their number and the number of targets, and the rate of casulties inflicted by the irregular forces is just proportional to their number.

    try:

    Code:
    >f=inline('[-.1*x(1)*x(2);-1*x(1)]','t','x')
    >[t, y]=ode45(f,[0,15],[10;15])
    The order of the arguments in the derivative is f(t,x) you had them the other way around.

    Also the initial value vector in ode45 is a column vector, you had a row vector.



    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Feb 2009
    Posts
    2
    Ah, thanks so much for the help!
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Issue with a factoring problem
    Posted in the Algebra Forum
    Replies: 13
    Last Post: October 24th 2011, 01:36 AM
  2. Replies: 2
    Last Post: February 19th 2011, 05:54 AM
  3. Word Problem issue
    Posted in the Algebra Forum
    Replies: 4
    Last Post: January 29th 2010, 10:42 AM
  4. Is this Matlab issue fixable or not?
    Posted in the Math Software Forum
    Replies: 2
    Last Post: May 4th 2009, 11:17 PM
  5. Replies: 2
    Last Post: September 28th 2008, 07:58 AM

Search Tags


/mathhelpforum @mathhelpforum