# Math Help - simple matlab question

1. ## 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"

2. Originally Posted by ezong
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.

3. Originally Posted by ezong
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