Results 1 to 3 of 3

Math Help - simple matlab question

  1. #1
    Newbie
    Joined
    Sep 2009
    Posts
    13

    simple matlab question

    Let's say I want to graph f(x)=x on matlab with x\in [0,10]
    How do you get matlab to graph the [0,1) part?
    It always says "Attempted to access (0); index must be a positive integer or logical"
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member
    Joined
    Dec 2008
    From
    Scotland
    Posts
    901
    Quote Originally Posted by ezong View Post
    Let's say I want to graph f(x)=x on matlab with x\in [0,10]
    How do you get matlab to graph the [0,1) part?
    It always says "Attempted to access (0); index must be a positive integer or logical"
    It seems you have set your interval up as an index of the variable, rather than an interval!

    Try this:

    x = 0:0.01:10;
    y = f(x)

    plot(x,y)

    What this does is it sets x up as a vector which contains all the values from 0 to 10 in steps of 0.01.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by ezong View Post
    Let's say I want to graph f(x)=x on matlab with x\in [0,10]
    How do you get matlab to graph the [0,1) part?
    It always says "Attempted to access (0); index must be a positive integer or logical"

    x=[0:10];
    y=f(x);
    plot(x,y);

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab. Simple???
    Posted in the Math Software Forum
    Replies: 5
    Last Post: June 28th 2010, 07:45 PM
  2. Replies: 14
    Last Post: April 23rd 2010, 03:52 AM
  3. Replies: 2
    Last Post: March 15th 2010, 03:33 AM
  4. Simple matlab, legend location help
    Posted in the Math Software Forum
    Replies: 3
    Last Post: October 20th 2009, 01:58 AM
  5. Simple Matlab problem
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 25th 2009, 12:07 AM

Search Tags


/mathhelpforum @mathhelpforum