MATLAB: How to ask MATLAB to predict the next value in a graph

estimateforecastpredict

I have a linear graph with the cost of advertising on a platform over time, versus the date. I am looking to use Matlab to estimate the next point on the graph.
I have looked at YPred, but I am unsure about how to format my data so that it understands what it needs to make the prediction. I am also unclear as to what type of model I would be specifying.
ypred = predict(mdl,DATASET)
is what I am using, but it doesn't make any sense.
Any suggestions or advice would be appreciated, I have exhausted the MATLAB resources sadly.

Best Answer

Use polyfit() and polyval():
coefficients = polyfit(t, cost, 1); % Do a linear fit
predictedCost = polyval(coefficients, t); % Get value of linear fit at time t.
Related Question