How to ask MATLAB to predict the next value in a graph
13 views (last 30 days)
Show older comments
Helena Leathers
on 18 Jan 2019
Commented: Helena Leathers
on 22 Jan 2019
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.
0 Comments
Accepted Answer
Image Analyst
on 18 Jan 2019
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.
More Answers (1)
Cris LaPierre
on 18 Jan 2019
You could also consider fitting the data using polyfit, then calculating the y value for a given x value using polyval. The this example in the documentation.
See Also
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!