MATLAB: Error using Polyfit, X and Y vectors must be the same size

errorpolyfit

plot(flip(AdjClose))
y = flip(AdjClose)
x = 1:503;
polyfit(y,x,0)
x is a 503*1 double and y is a 1*503 double. I wonder how can I make them the same size?

Best Answer

You can use the transpose function. For example, you could have done
y = flip(AdjClose).'