Results 1 to 3 of 3

Math Help - need help with matlab function

  1. #1
    Newbie
    Joined
    Feb 2010
    Posts
    3

    need help with matlab function

    ok for some reason i cant get this function to work.

    in one file i have
    t=[0:.1:30];
    x=postion(t)
    plot(t,x)

    and in the other file i have

    function x=postion(t)
    if 0<=t<=10
    y=.5*t^2;
    elseif 10<=t<=20
    y=.5*t^3-t^2+15*t-50;
    elseif 20<=t<=30
    y=.0025*t^4-.15*t^3+135*t-1650;
    end
    end

    and i cant get it to work
    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 truong123 View Post
    ok for some reason i cant get this function to work.

    in one file i have

    Code:
    t=[0:.1:30];
    x=postion(t)
    plot(t,x)
    and in the other file i have

    Code:
    function x=postion(t)
    if 0<=t<=10
        y=.5*t^2;
    elseif 10<=t<=20
        y=.5*t^3-t^2+15*t-50;
    elseif 20<=t<=30
        y=.0025*t^4-.15*t^3+135*t-1650;
    end
    end
    and i cant get it to work
    When you run it what error message do you get? Have you considered running this under debug?

    It might help if your return value in the function was something you have calculated though.


    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Feb 2010
    Posts
    3
    i get errors in both files. in the 1st file i get

    ??? Undefined function or method 'postion' for input arguments of type 'double'.

    Error in ==> g233x23 at 8
    x=postion(t)

    and in the function file i get

    ??? Input argument "t" is undefined.

    Error in ==> position at 2
    if 0<=t<=10
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. need a matlab function
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 1st 2011, 10:52 PM
  2. Matlab function
    Posted in the Math Software Forum
    Replies: 2
    Last Post: April 17th 2010, 08:11 PM
  3. Please help with MATLAB function
    Posted in the Math Software Forum
    Replies: 1
    Last Post: April 16th 2010, 04:21 AM
  4. is there any function in MATLAB?
    Posted in the Math Software Forum
    Replies: 1
    Last Post: April 4th 2010, 01:57 AM
  5. Matlab while function
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 9th 2009, 11:46 PM

Search Tags


/mathhelpforum @mathhelpforum