I have been trying to write an m file in matlab which can plot a

function which changes within the limits.

I can plot a function within a given limit. But the function I

have to plot is discontinuous.

The function is

y = exp(x+1) x < -1

y = 2 + cos(pi*x) -1 <= x < 5

y = 10(x - 5) + 1 x >=5

And I want to plot y for -2 < x < 6

I can plot if it is simply y = exp(x+1) for -2 < x < 6

but there are three conditions on the top. how do i

write the m file ?

thanks