# Plotting in Matlab

1. Mar 2, 2005

### Electro

Hi there,
I have a simple function and I want to plot it in matlab but i get an error.
Maybe someone can help. The function is of the type 1/(X^3 + X^2 +1)
I can plot a polynomial but I have no idea about the function above.
Thnx

2. Mar 2, 2005

### xanthym

Your function is UNDEFINED (Illegal) at X=(-1.4656) because the denominator becomes 0 at this point which involves division by zero. If your graph includes this X value, that's probably the problem.

~~

Last edited: Mar 2, 2005
3. Mar 3, 2005

### Jayboy

You could do the following:

1. Decide on your range xmax, xmin
2. Decide on the number of points you want to plot (say N=1,000)
3. Declare an Axis vector with the axis points and a Y = zeros(1,N) vector to receive the results of the calculation
4. Use a loop to perform the calc y = ...... from xmin to xmax in steps (xmax - xmin)/N and populate the Y vector. Include a check which says if the calc gives an error, put zero in that cell.
5. Plot Y vs Axis.

Others with more Matlab experience may have a much better solution but let me know if you want me to knock together some useable code.