I'm trying to plot this function


in Matlab using 101 evenly spaced x values. If I just say

fplot(fun, [-1 3], 'o') 

the graph is the correct shape but the actual values of the points are determined by Matlab to give the best shape of the graph. I want to tell it exactly where to put the points, 101 evenly spaced between -1 and 3.


1 Answer 1


You can use linspace function,

  • $\begingroup$ Note that this also uses a different plot command: fplot wants as its first argument a string or a function handle, plot a vector. This will probably be confusing. $\endgroup$ Commented Oct 25, 2014 at 17:34
  • $\begingroup$ Thanks guys, this worked. I had tried doing this with fplot and it wasn't working correctly, so this is much better! $\endgroup$
    – user11609
    Commented Oct 25, 2014 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.