%% Display Axis Lines through Origin
% By default, the x-axis and y-axis appear along the outer bounds of the axes. Change the location of the axis lines so that they cross at the origin point (0,0) by setting the XAxisLocation and YAxisLocation properties of the Axes object.  Set XAxisLocation to either 'top', 'bottom', or 'origin'.  Set YAxisLocation to either 'left', 'right', or 'origin'. These properties only apply to axes in a 2-D view.

x = linspace(-5,5);
y = sin(x);
plot(x,y)

ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';

%
% Remove the axes box outline.

box off

% Copyright 2012 The MathWorks, Inc.