# How to plot function with evenly spaced x values in Matlab

I'm trying to plot this function

func=exp(x-sqrt(2))-cos(x-sqrt(2))-(x-sqrt(2))


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.

You can use linspace function,
x=linspace(-1,3,101);

• 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. – Federico Poloni Oct 25 '14 at 17:34