clear;clc;close all

y0 = 0.1;       %initial condition
tspan = [0 10]; % time span
options = odeset('MaxStep',0.01);
[t,y] = ode15s(@fun,tspan,y0,options);

figure
plot(t,y,'Linewidth',1)
xlabel('time')
ylabel('y')
set(gca,'fontsize',20)
grid on

function dydt = fun(t,y)
if y<1          % non-smooth point
    dydt = y;  
else
    dydt = -y+2;
end

end
