MATLAB: Add lines along the axes

MATLABplotting

I need to add lines along the x and y axes, but I don't want to move the entire axis to the origin. (essentially gridlines, but only at x=0 and y=0) Is this doable easily?

Best Answer

I am not certain what you want.
Try this:
x = linspace(-2, 5, 250);
y = sin(2*pi*x + 0.2) + 0.3;
figure
plot(x, y)
hold on
plot([0 0], ylim, '--') % Dashed Vertical Line at x=0
plot(xlim, [0 0], '--') % Dashed Horizontal Line at y=0
hold off
grid