MATLAB: How to select origin for plotting graph

helporiginplot

i have y=[1,5,8,3,9] and x has to be the origin from where the graph will have origin, suppose user want origin a y[8] so point(0,8) will be the origin and the other points will be according to that.Please help me with this.

Best Answer

Suppose in this case you want origin at y(3)
y= [1,5,8,3,9];
n = 3;
x = -(n-1):numel(y)-n; % or x = (0:numel(y)-1)-n+1;
plot(x, y);