Results 1 to 2 of 2

Math Help - ODE matlab

  1. #1
    Newbie
    Joined
    Apr 2010
    Posts
    3

    ODE matlab

    Hi Friends
    I want to plot variables (b,u) that are in function "step" .
    function main
    [t,v]=ode45('step',[0 20],0,[]);
    plot(t,v)

    function dv=step(t,v)
    c1=1;
    if t<10
    u=1;
    else
    u=-1;
    end
    dv=c1*u-2*v;
    b=dv/2;

    but these variables are unknown in function "main".
    thanks.
    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 madjid222 View Post
    Hi Friends
    I want to plot variables (b,u) that are in function "step" .
    function main
    [t,v]=ode45('step',[0 20],0,[]);
    plot(t,v)

    function dv=step(t,v)
    c1=1;
    if t<10
    u=1;
    else
    u=-1;
    end
    dv=c1*u-2*v;
    b=dv/2;

    but these variables are unknown in function "main".
    thanks.
    Try (untested code warning):

    Code:
    function main
    [t,v]=ode45('step',[0 20],0,[]);
    plot(t,v)
    u=1+(t>=10)*(-2);
    b=step(t,v)/2
    
    function dv=step(t,v)
    c1=1;
    u=1-(t>=10)*(-2);
    dv=c1*u-2*v;
    b=dv/2;
    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 11th 2010, 03:59 AM
  2. Matlab FFT Help
    Posted in the Math Software Forum
    Replies: 0
    Last Post: June 3rd 2009, 01:48 PM
  3. help about ODE in matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 31st 2009, 04:10 AM
  4. Matlab
    Posted in the Math Software Forum
    Replies: 0
    Last Post: November 6th 2008, 09:46 AM
  5. Matlab
    Posted in the Calculus Forum
    Replies: 3
    Last Post: August 20th 2008, 11:39 PM

Search Tags


/mathhelpforum @mathhelpforum