This is an example of a first order differential equation. To solve it we need to find an integrating factor so that the left-hand side becomes an easily integrable expression.
This is achieved in this case by calculating e∫-sin(x)dx=ecos(x) which becomes the integrating factor:
ecos(x)dy/dx-sin(x)ecos(x)y=2sin(x)ecos(x),
(d/dx)(ecos(x)y)=2sin(x)ecos(x),
yecos(x)=2∫sin(x)ecos(x)dx=-2ecos(x)+C where C is the constant of integration.
Therefore y=-2+Ce-cos(x).
CHECK:
y=-2+Ce-cos(x), so Ce-cos(x)=y+2
dy/dx=-Csin(x)e-cos(x)=ysin(x)+2sin(x),
dy/dx-ysin(x)=2sin(x)✔️
-1≤cos(x)≤1 no matter what size x is, so e-cos(x) can only lie between 1/e and e, which are not transient values. The appearance of y when graphed is a series of waves (like sine) with fixed amplitude and period. The constant C determines the magnitude of the amplitude. When C=0, y=-2, a flat line, of course. On either side of C=0, the wave pattern is largely below or above the x-axis. The function is continuous, and is also continuously differentiable, the interval being (-∞,∞).
I don't have access to MATLAB, but I hope my solution helps. Here is a graph using a positive value of C:
Picture by courtesy of Desmos.com/calculator
As C shrinks to zero the graph shrinks to the line y=-2.